From cbafaaf151f292f76f01a38f6427f35bc82271dd Mon Sep 17 00:00:00 2001 From: Snowykami Date: Sat, 1 Mar 2025 02:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20=E4=BD=BF=E7=94=A8Liteyukiflare?= =?UTF-8?q?=E5=AF=B9GitHub=20Page=E6=96=87=E6=A1=A3=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BA=9A=E5=A4=AA=E5=9C=B0=E5=8C=BA=E5=8A=A0=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config/common.ts | 144 ++++++++++++++++--------------- docs/.vitepress/config/en.ts | 2 +- docs/.vitepress/config/ja.ts | 2 +- docs/.vitepress/config/zh.ts | 2 +- 4 files changed, 78 insertions(+), 72 deletions(-) diff --git a/docs/.vitepress/config/common.ts b/docs/.vitepress/config/common.ts index 765cfbf..4bb406f 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 8edcfc7..19a64c5 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 51bc0eb..8e69efc 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 e15cb45..6be33ac 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', } },