feat(docs): enhance documentation structure and add Docker support for standalone Next.js app

This commit is contained in:
HouYunFei
2026-06-02 13:23:11 +08:00
parent 7802771e56
commit 6413011e54
24 changed files with 250 additions and 94 deletions
+1 -4
View File
@@ -1,6 +1,6 @@
import { getMDXComponents } from '@/components/mdx';
import { gitConfig } from '@/lib/shared';
import { getPageImage, getPageMarkdownUrl, source } from '@/lib/source';
import { getPageMarkdownUrl, source } from '@/lib/source';
import type { Metadata } from 'next';
import { createRelativeLink } from 'fumadocs-ui/mdx';
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/page';
@@ -41,8 +41,5 @@ export function getDocPageMetadata(page: DocPageData): Metadata {
return {
title: page.data.title,
description: page.data.description,
openGraph: {
images: getPageImage(page).url,
},
};
}
+54
View File
@@ -0,0 +1,54 @@
type OramaTokenizer = {
language: string;
normalizationCache: Map<string, string>;
tokenize: (raw: string, language?: string, prop?: string, withCache?: boolean) => string[];
};
const wordPattern = /[\p{Script=Han}]+|[a-z0-9][a-z0-9_'-]*/giu;
const hanPattern = /^\p{Script=Han}+$/u;
const chineseSegmenter = 'Segmenter' in Intl ? new Intl.Segmenter('zh-CN', { granularity: 'word' }) : null;
function getChineseSegments(value: string) {
if (!chineseSegmenter) return [];
return Array.from(chineseSegmenter.segment(value))
.filter((item) => item.isWordLike)
.map((item) => item.segment);
}
function addChineseTokens(tokens: string[], value: string) {
const chars = Array.from(value);
if (chars.length <= 12) tokens.push(value);
tokens.push(...getChineseSegments(value));
for (let size = 1; size <= 3; size += 1) {
if (chars.length < size) continue;
for (let i = 0; i <= chars.length - size; i += 1) {
tokens.push(chars.slice(i, i + size).join(''));
}
}
}
export function createDocsSearchTokenizer(): OramaTokenizer {
return {
language: 'zh-CN',
normalizationCache: new Map(),
tokenize(raw) {
if (typeof raw !== 'string') return [raw];
const tokens: string[] = [];
const input = raw.normalize('NFKC').toLowerCase();
for (const match of input.matchAll(wordPattern)) {
const value = match[0];
if (hanPattern.test(value)) {
addChineseTokens(tokens, value);
} else {
tokens.push(value);
}
}
return Array.from(new Set(tokens.filter(Boolean)));
},
};
}
-1
View File
@@ -1,6 +1,5 @@
export const appName = '无限画布';
export const docsRoute = '/docs';
export const docsImageRoute = '/og/docs';
export const docsContentRoute = '/llms.mdx/docs';
// fill this with your actual GitHub info, for example:
+1 -10
View File
@@ -1,6 +1,6 @@
import { docs } from 'collections/server';
import { loader } from 'fumadocs-core/source';
import { docsContentRoute, docsImageRoute, docsRoute } from './shared';
import { docsContentRoute, docsRoute } from './shared';
// See https://fumadocs.dev/docs/headless/source-api for more info
export const source = loader({
@@ -9,15 +9,6 @@ export const source = loader({
plugins: [],
});
export function getPageImage(page: (typeof source)['$inferPage']) {
const segments = [...page.slugs, 'image.png'];
return {
segments,
url: `${docsImageRoute}/${segments.join('/')}`,
};
}
export function getPageMarkdownUrl(page: (typeof source)['$inferPage']) {
const segments = [...page.slugs, 'content.md'];