mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
feat: upgrade fumadocs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { create } from "@orama/orama";
|
||||
import { useDocsSearch } from "fumadocs-core/search/client";
|
||||
import { staticClient } from "fumadocs-core/search/client/orama-static";
|
||||
import {
|
||||
SearchDialog,
|
||||
SearchDialogClose,
|
||||
@@ -13,19 +13,12 @@ import {
|
||||
} from "fumadocs-ui/components/dialog/search";
|
||||
import { useI18n } from "fumadocs-ui/contexts/i18n";
|
||||
|
||||
function initOrama() {
|
||||
return create({
|
||||
schema: { _: "string" },
|
||||
language: "english",
|
||||
});
|
||||
}
|
||||
|
||||
export default function DefaultSearchDialog(props: SharedProps) {
|
||||
const { locale } = useI18n();
|
||||
const { search, setSearch, query } = useDocsSearch({
|
||||
type: "static",
|
||||
initOrama,
|
||||
client: staticClient({
|
||||
locale,
|
||||
}),
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ const EnvSchema = yup.object({
|
||||
});
|
||||
|
||||
type EnvSchema = yup.InferType<typeof EnvSchema>;
|
||||
function safeParseYup<T>(schema: yup.ObjectSchema<any>, data: unknown) {
|
||||
function safeParseYup<T>(schema: yup.AnySchema, data: unknown) {
|
||||
try {
|
||||
const validatedData = schema.validateSync(data, {
|
||||
abortEarly: false,
|
||||
|
||||
+17
-25
@@ -1,6 +1,5 @@
|
||||
import type { Route } from "./+types/page";
|
||||
|
||||
import browserCollections from "collections/browser";
|
||||
import { useFumadocsLoader } from "fumadocs-core/source/client";
|
||||
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
||||
import {
|
||||
@@ -11,13 +10,14 @@ import {
|
||||
MarkdownCopyButton,
|
||||
ViewOptionsPopover,
|
||||
} from "fumadocs-ui/layouts/docs/page";
|
||||
import { use } from "react";
|
||||
|
||||
import { useMDXComponents } from "@/components/mdx";
|
||||
import { baseOptions } from "@/lib/layout.shared";
|
||||
import { getPageMarkdownUrl, source } from "@/lib/source";
|
||||
import { docs, getPageMarkdownUrl, source } from "@/lib/source";
|
||||
|
||||
export async function loader({ params }: Route.LoaderArgs) {
|
||||
const slugs = params["*"].split("/").filter((v: string | any[]) => v.length > 0);
|
||||
const slugs = params["*"].split("/").filter((v) => v.length > 0);
|
||||
const page = source.getPage(slugs);
|
||||
if (!page) throw new Response("Not found", { status: 404 });
|
||||
|
||||
@@ -28,24 +28,20 @@ export async function loader({ params }: Route.LoaderArgs) {
|
||||
};
|
||||
}
|
||||
|
||||
const clientLoader = browserCollections.docs.createClientLoader({
|
||||
component(
|
||||
{ toc, frontmatter, default: Mdx },
|
||||
// you can define props for the component
|
||||
{
|
||||
markdownUrl,
|
||||
path,
|
||||
}: {
|
||||
markdownUrl: string;
|
||||
path: string;
|
||||
},
|
||||
) {
|
||||
function Content({ path, markdownUrl }: { path: string; markdownUrl: string }) {
|
||||
const page = docs.getPage(path);
|
||||
if (!page) throw new Error(`unknown page: ${path}`);
|
||||
|
||||
// content is loaded lazily, call `page.preload()` in the loader to avoid suspending
|
||||
const { toc } = use(page.load());
|
||||
const Mdx = page.body;
|
||||
|
||||
return (
|
||||
<DocsPage toc={toc} tableOfContent={{ style: "clerk" }}>
|
||||
<title>{frontmatter.title}</title>
|
||||
<meta name="description" content={frontmatter.description} />
|
||||
<DocsTitle>{frontmatter.title}</DocsTitle>
|
||||
<DocsDescription>{frontmatter.description}</DocsDescription>
|
||||
<title>{page.title}</title>
|
||||
<meta name="description" content={page.description} />
|
||||
<DocsTitle>{page.title}</DocsTitle>
|
||||
<DocsDescription>{page.description}</DocsDescription>
|
||||
<div className="-mt-4 flex flex-row items-center gap-2 border-b pb-6">
|
||||
<MarkdownCopyButton markdownUrl={markdownUrl} />
|
||||
<ViewOptionsPopover
|
||||
@@ -58,18 +54,14 @@ const clientLoader = browserCollections.docs.createClientLoader({
|
||||
</DocsBody>
|
||||
</DocsPage>
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export default function Page({ loaderData }: Route.ComponentProps) {
|
||||
const { pageTree, path, markdownUrl } = useFumadocsLoader(loaderData);
|
||||
|
||||
return (
|
||||
<DocsLayout {...baseOptions()} tree={pageTree}>
|
||||
{clientLoader.useContent(loaderData.path, {
|
||||
markdownUrl,
|
||||
path,
|
||||
})}
|
||||
<Content path={path} markdownUrl={markdownUrl} />
|
||||
</DocsLayout>
|
||||
);
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,17 +1,8 @@
|
||||
import { stopwords as mandarinStopwords } from "@orama/stopwords/mandarin";
|
||||
import { createTokenizer } from "@orama/tokenizers/mandarin";
|
||||
import { createFromSource } from "fumadocs-core/search/server";
|
||||
|
||||
import { source } from "@/lib/source";
|
||||
|
||||
const server = createFromSource(source, {
|
||||
components: {
|
||||
tokenizer: createTokenizer({
|
||||
language: "mandarin",
|
||||
stopWords: mandarinStopwords,
|
||||
}),
|
||||
},
|
||||
});
|
||||
const server = createFromSource(source);
|
||||
|
||||
export async function loader() {
|
||||
return server.staticGET();
|
||||
|
||||
+11
-1
@@ -1,6 +1,16 @@
|
||||
import { docs } from "collections/server";
|
||||
import { loader, type InferPageType } from "fumadocs-core/source";
|
||||
import { lucideIconsPlugin } from "fumadocs-core/source/lucide-icons";
|
||||
import { defineDocs } from "fumadocs-mdx/macro";
|
||||
|
||||
export const docs = defineDocs({
|
||||
dir: "content/docs",
|
||||
docs: {
|
||||
async: true,
|
||||
postprocess: {
|
||||
includeProcessedMarkdown: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const source = loader({
|
||||
source: docs.toFumadocsSource(),
|
||||
|
||||
@@ -53,7 +53,7 @@ const urlPatternIsNeeded = (shellType: string) => {
|
||||
const isInvalidUrl = (urlPattern: string | undefined) =>
|
||||
urlPattern === "/" || urlPattern === "/*" || !urlPattern?.startsWith("/") || !urlPattern;
|
||||
|
||||
export const useYupValidationResolver = (validationSchema: yup.ObjectSchema<any>, t: TFunction) =>
|
||||
export const useYupValidationResolver = (validationSchema: yup.AnySchema, t: TFunction) =>
|
||||
useCallback(
|
||||
async (data: MemShellFormSchema, _context: any): Promise<ValidationResult> => {
|
||||
try {
|
||||
@@ -157,10 +157,7 @@ export const probeShellFormSchema = yup.object().shape({
|
||||
|
||||
type ProbeValidationResult = ResolverResult<ProbeShellFormSchema>;
|
||||
|
||||
export const useYupValidationProbeResolver = (
|
||||
validationSchema: yup.ObjectSchema<any>,
|
||||
t: TFunction,
|
||||
) =>
|
||||
export const useYupValidationProbeResolver = (validationSchema: yup.AnySchema, t: TFunction) =>
|
||||
useCallback(
|
||||
async (data: ProbeShellFormSchema, _context: any): Promise<ProbeValidationResult> => {
|
||||
try {
|
||||
|
||||
+403
-792
File diff suppressed because it is too large
Load Diff
+32
-36
@@ -6,63 +6,59 @@
|
||||
"build": "react-router build --mode production && bun run copy-build.js",
|
||||
"dev": "react-router dev",
|
||||
"start": "serve ./build/client",
|
||||
"types:check": "react-router typegen && fumadocs-mdx && tsc --noEmit",
|
||||
"postinstall": "fumadocs-mdx",
|
||||
"types:check": "react-router typegen && tsc --noEmit",
|
||||
"lint": "oxlint",
|
||||
"lint:fix": "oxlint --fix --fix-suggestions --fix-dangerously .",
|
||||
"fmt": "oxfmt",
|
||||
"fmt:check": "oxfmt --check"
|
||||
},
|
||||
"dependencies": {
|
||||
"@base-ui/react": "^1.6.0",
|
||||
"@hookform/resolvers": "^5.4.0",
|
||||
"@orama/orama": "^3.1.18",
|
||||
"@orama/stopwords": "^3.1.18",
|
||||
"@orama/tokenizers": "^3.1.18",
|
||||
"@react-router/node": "^7.15.1",
|
||||
"@base-ui/react": "^1.7.0",
|
||||
"@hookform/resolvers": "^5.9.1",
|
||||
"@react-router/node": "^8.3.1",
|
||||
"@run-slicer/cfr": "file:./vendor/cfr",
|
||||
"@tanstack/react-query": "^5.101.2",
|
||||
"@tanstack/react-query": "^5.102.8",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"framer-motion": "^12.42.0",
|
||||
"fumadocs-core": "^16.10.6",
|
||||
"fumadocs-mdx": "15.0.12",
|
||||
"fumadocs-ui": "16.10.5",
|
||||
"i18next": "^26.3.3",
|
||||
"isbot": "^5.1.44",
|
||||
"lucide-react": "^1.21.0",
|
||||
"motion": "^12.42.0",
|
||||
"react": "^19.2.7",
|
||||
"framer-motion": "^13.1.1",
|
||||
"fumadocs-core": "^16.15.4",
|
||||
"fumadocs-mdx": "15.4.0",
|
||||
"fumadocs-ui": "16.15.4",
|
||||
"i18next": "^26.4.0",
|
||||
"isbot": "^5.2.2",
|
||||
"lucide-react": "^1.37.0",
|
||||
"motion": "^13.1.1",
|
||||
"react": "^19.2.8",
|
||||
"react-copy-to-clipboard": "^5.1.1",
|
||||
"react-dom": "^19.2.7",
|
||||
"react-hook-form": "^7.80.0",
|
||||
"react-i18next": "^17.0.8",
|
||||
"react-medium-image-zoom": "^5.4.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"react-hook-form": "^7.87.0",
|
||||
"react-i18next": "^17.0.12",
|
||||
"react-medium-image-zoom": "^5.4.9",
|
||||
"react-syntax-highlighter": "^16.1.1",
|
||||
"sonner": "^2.0.7",
|
||||
"sonner": "^2.0.8",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"yup": "^1.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-router/dev": "^7.15.1",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
"@react-router/dev": "^8.3.1",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@types/mdx": "^2.0.14",
|
||||
"@types/node": "^26.0.1",
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/node": "^26.4.0",
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-copy-to-clipboard": "^5.0.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/react-dom": "^19.2.5",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"baseline-browser-mapping": "^2.10.40",
|
||||
"oxfmt": "^0.56.0",
|
||||
"oxlint": "^1.71.0",
|
||||
"react-router-devtools": "^6.2.1",
|
||||
"baseline-browser-mapping": "^2.11.20",
|
||||
"oxfmt": "^0.65.0",
|
||||
"oxlint": "^1.80.0",
|
||||
"react-router-devtools": "^6.2.3",
|
||||
"rimraf": "^6.1.3",
|
||||
"serve": "^14.2.6",
|
||||
"tailwindcss": "^4.3.1",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.1.0",
|
||||
"vite-plugin-devtools-json": "^1.0.0",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"typescript": "^7.0.2",
|
||||
"vite": "^8.2.2",
|
||||
"vite-plugin-devtools-json": "^1.1.0",
|
||||
"vite-tsconfig-paths": "^6.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { defineConfig, defineDocs } from "fumadocs-mdx/config";
|
||||
|
||||
export const docs = defineDocs({
|
||||
dir: "content/docs",
|
||||
docs: {
|
||||
postprocess: {
|
||||
includeProcessedMarkdown: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default defineConfig();
|
||||
+1
-2
@@ -9,8 +9,7 @@
|
||||
"jsx": "react-jsx",
|
||||
"rootDirs": [".", "./.react-router/types"],
|
||||
"paths": {
|
||||
"@/*": ["./app/*"],
|
||||
"collections/*": ["./.source/*"]
|
||||
"@/*": ["./app/*"]
|
||||
},
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
|
||||
+3
-13
@@ -1,12 +1,9 @@
|
||||
import { reactRouter } from "@react-router/dev/vite";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import mdx from "fumadocs-mdx/vite";
|
||||
import path from "node:path";
|
||||
import { fumadocsMdx } from "fumadocs-mdx/vite";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import devtoolsJson from "vite-plugin-devtools-json";
|
||||
|
||||
import * as MdxConfig from "./source.config";
|
||||
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "VITE_APP_");
|
||||
const isDev = command === "serve";
|
||||
@@ -14,17 +11,10 @@ export default defineConfig(({ command, mode }) => {
|
||||
|
||||
return {
|
||||
base: isDev || !contextPath ? "/" : `${contextPath}/`,
|
||||
plugins: [mdx(MdxConfig), tailwindcss(), reactRouter(), devtoolsJson()],
|
||||
plugins: [fumadocsMdx(), tailwindcss(), reactRouter(), devtoolsJson()],
|
||||
resolve: {
|
||||
tsconfigPaths: true,
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./app"),
|
||||
...(!isDev
|
||||
? {
|
||||
"react-dom/server": "react-dom/server.node",
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
alias: !isDev ? { "react-dom/server": "react-dom/server.node" } : {},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user