diff --git a/docs/.vitepress/config/common.ts b/docs/.vitepress/config/common.ts index 765cfbfd..4bb406ff 100755 --- a/docs/.vitepress/config/common.ts +++ b/docs/.vitepress/config/common.ts @@ -1,81 +1,87 @@ -import { VitePressSidebarOptions } from "vitepress-sidebar/types" +import { VitePressSidebarOptions } from "vitepress-sidebar/types"; export const gitea = { - svg: '' -} + svg: '', +}; -export const defaultLang = 'zh' +export const defaultLang = "zh"; const commonSidebarOptions: VitePressSidebarOptions = { - collapsed: true, - convertSameNameSubFileToGroupIndexPage: true, - useTitleFromFrontmatter: true, - useFolderTitleFromIndexFile: false, - useFolderLinkFromIndexFile: true, - useTitleFromFileHeading: true, - rootGroupText: 'MARSHOAI', - includeFolderIndexFile: true, - sortMenusByFrontmatterOrder: true, -} + collapsed: true, + convertSameNameSubFileToGroupIndexPage: true, + useTitleFromFrontmatter: true, + useFolderTitleFromIndexFile: false, + useFolderLinkFromIndexFile: true, + useTitleFromFileHeading: true, + rootGroupText: "MARSHOAI", + includeFolderIndexFile: true, + sortMenusByFrontmatterOrder: true, +}; export function generateSidebarConfig(): VitePressSidebarOptions[] { - let sections = ["dev", "start"] - let languages = ['zh', 'en'] - let ret: VitePressSidebarOptions[] = [] - for (let language of languages) { - for (let section of sections) { - if (language === defaultLang) { - ret.push({ - basePath: `/${section}/`, - scanStartPath: `docs/${language}/${section}`, - resolvePath: `/${section}/`, - ...commonSidebarOptions - }) - } else { - ret.push({ - basePath: `/${language}/${section}/`, - scanStartPath: `docs/${language}/${section}`, - resolvePath: `/${language}/${section}/`, - ...commonSidebarOptions - }) - } - } + let sections = ["dev", "start"]; + let languages = ["zh", "en"]; + let ret: VitePressSidebarOptions[] = []; + for (let language of languages) { + for (let section of sections) { + if (language === defaultLang) { + ret.push({ + basePath: `/${section}/`, + scanStartPath: `docs/${language}/${section}`, + resolvePath: `/${section}/`, + ...commonSidebarOptions, + }); + } else { + ret.push({ + basePath: `/${language}/${section}/`, + scanStartPath: `docs/${language}/${section}`, + resolvePath: `/${language}/${section}/`, + ...commonSidebarOptions, + }); + } } - return ret + } + return ret; } export const ThemeConfig = { - getEditLink: (editPageText: string): { pattern: (params: { filePath: string; }) => string; text: string; } => { - return { - pattern: ({filePath}: { filePath: string; }): string => { - if (!filePath) { - throw new Error("filePath is undefined"); - } - const regex = /^(dev\/api|[^\/]+\/dev\/api)/; - if (regex.test(filePath)) { - filePath = filePath.replace(regex, '') - .replace('index.md', '__init__.py') - .replace('.md', '.py'); - const fileName = filePath.split('/').pop(); - const parentFolder = filePath.split('/').slice(-2, -1)[0]; - if (fileName && parentFolder && fileName.split('.')[0] === parentFolder) { - filePath = filePath.split('/').slice(0, -1).join('/') + '/__init__.py'; - } - return `https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/${filePath}`; - } else { - return `https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/docs/${filePath}`; - } - }, - text: editPageText - }; - }, + getEditLink: ( + editPageText: string + ): { pattern: (params: { filePath: string }) => string; text: string } => { + return { + pattern: ({ filePath }: { filePath: string }): string => { + if (!filePath) { + throw new Error("filePath is undefined"); + } + const regex = /^(dev\/api|[^\/]+\/dev\/api)/; + if (regex.test(filePath)) { + filePath = filePath + .replace(regex, "") + .replace("index.md", "__init__.py") + .replace(".md", ".py"); + const fileName = filePath.split("/").pop(); + const parentFolder = filePath.split("/").slice(-2, -1)[0]; + if ( + fileName && + parentFolder && + fileName.split(".")[0] === parentFolder + ) { + filePath = + filePath.split("/").slice(0, -1).join("/") + "/__init__.py"; + } + return `https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/${filePath}`; + } else { + return `https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/docs/${filePath}`; + } + }, + text: editPageText, + }; + }, - getOutLine: (label: string): { label: string; level: [number, number]; } => { - return { - label: label, - level: [2, 6] - }; - }, - - copyright: 'Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved' -} \ No newline at end of file + getOutLine: (label: string): { label: string; level: [number, number] } => { + return { + label: label, + level: [2, 6], + }; + }, +}; diff --git a/docs/.vitepress/config/en.ts b/docs/.vitepress/config/en.ts index 8edcfc7e..19a64c54 100755 --- a/docs/.vitepress/config/en.ts +++ b/docs/.vitepress/config/en.ts @@ -23,7 +23,7 @@ export const en = defineConfig({ lightModeSwitchTitle: 'Light', darkModeSwitchTitle: 'Dark', footer: { - message: "The document is being improved. Suggestions are welcome.", + message: "The document is being improved. Suggestions are welcome.
Webpage is accelerated by Liteyukiflare CDN.", copyright: '© 2024 Liteyuki Studio', } }, diff --git a/docs/.vitepress/config/ja.ts b/docs/.vitepress/config/ja.ts index 51bc0eb1..8e69efc1 100755 --- a/docs/.vitepress/config/ja.ts +++ b/docs/.vitepress/config/ja.ts @@ -23,7 +23,7 @@ export const ja = defineConfig({ lightModeSwitchTitle: 'ライト', darkModeSwitchTitle: 'ダーク', footer: { - message: "ドキュメントは改善中です。ご意見をお待ちしております。", + message: "ドキュメントは改善中です。ご意見をお待ちしております。
ウェブページは Liteyukiflare CDN によって加速されています。", copyright: '© 2024 Liteyuki Studio', } }, diff --git a/docs/.vitepress/config/zh.ts b/docs/.vitepress/config/zh.ts index e15cb452..6be33ac7 100644 --- a/docs/.vitepress/config/zh.ts +++ b/docs/.vitepress/config/zh.ts @@ -23,7 +23,7 @@ export const zh = defineConfig({ lightModeSwitchTitle: '轻色模式', darkModeSwitchTitle: '深色模式', footer: { - message: "文档完善中,欢迎提出建议或帮助我们完善。", + message: "文档完善中,欢迎提出建议或帮助我们完善。
网页由 Liteyukiflare CDN 提供加速服务。", copyright: '© 2024 Liteyuki Studio', } },