From 575993ebc4aa091ed4b328a1d68f16d276c22204 Mon Sep 17 00:00:00 2001 From: Snowykami Date: Tue, 17 Dec 2024 01:36:31 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=9B=B4=E6=96=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=BB=E9=A2=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=92=8C=E7=BC=96=E8=BE=91=E9=93=BE=E6=8E=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E5=A4=9A=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config/common.ts | 36 ++++++++++++++++++++++ docs/.vitepress/config/en.ts | 2 ++ docs/.vitepress/config/index.ts | 1 + docs/.vitepress/config/ja.ts | 2 ++ docs/.vitepress/config/zh.ts | 2 ++ nonebot_plugin_marshoai/plugin/__init__.py | 2 +- 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/.vitepress/config/common.ts b/docs/.vitepress/config/common.ts index cfb1cd6b..765cfbfd 100755 --- a/docs/.vitepress/config/common.ts +++ b/docs/.vitepress/config/common.ts @@ -42,4 +42,40 @@ export function generateSidebarConfig(): VitePressSidebarOptions[] { } } 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 + }; + }, + + 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 diff --git a/docs/.vitepress/config/en.ts b/docs/.vitepress/config/en.ts index 56561b17..8edcfc7e 100755 --- a/docs/.vitepress/config/en.ts +++ b/docs/.vitepress/config/en.ts @@ -1,4 +1,5 @@ import {defineConfig} from 'vitepress' +import { ThemeConfig } from './common' export const en = defineConfig({ lang: "en-US", @@ -14,6 +15,7 @@ export const en = defineConfig({ {text: 'Usage', link: '/en/start/install'}, {text: 'Develop', link: '/en/dev/extension'}, ], + editLink: ThemeConfig.getEditLink('Edit this page'), langMenuLabel: 'Language', returnToTopLabel: 'To top', sidebarMenuLabel: 'Option', diff --git a/docs/.vitepress/config/index.ts b/docs/.vitepress/config/index.ts index ca4a88cf..e05f5696 100755 --- a/docs/.vitepress/config/index.ts +++ b/docs/.vitepress/config/index.ts @@ -36,4 +36,5 @@ export default defineConfig({ en: { label: "English", ...en }, ja: { label: "日本語", ...ja }, }, + lastUpdated: true, }) diff --git a/docs/.vitepress/config/ja.ts b/docs/.vitepress/config/ja.ts index 726889da..51bc0eb1 100755 --- a/docs/.vitepress/config/ja.ts +++ b/docs/.vitepress/config/ja.ts @@ -1,4 +1,5 @@ import {defineConfig} from 'vitepress' +import { ThemeConfig } from './common' export const ja = defineConfig({ lang: "ja-JP", @@ -14,6 +15,7 @@ export const ja = defineConfig({ {text: '使用方法', link: '/ja/start/install'}, {text: '開発', link: '/ja/dev/extension'}, ], + editLink: ThemeConfig.getEditLink('このページを編集'), langMenuLabel: '言語', returnToTopLabel: 'トップへ戻る', sidebarMenuLabel: 'オプション', diff --git a/docs/.vitepress/config/zh.ts b/docs/.vitepress/config/zh.ts index 896cb4ab..a3196706 100755 --- a/docs/.vitepress/config/zh.ts +++ b/docs/.vitepress/config/zh.ts @@ -1,4 +1,5 @@ import {defineConfig} from 'vitepress' +import { ThemeConfig } from './common' export const zh = defineConfig({ lang: "zh-Hans", @@ -14,6 +15,7 @@ export const zh = defineConfig({ {text: '使用', link: '/start/install'}, {text: '开发', link: '/dev/extension'}, ], + editLink: ThemeConfig.getEditLink('编辑此页面'), langMenuLabel: '语言', returnToTopLabel: '返回顶部', sidebarMenuLabel: '菜单', diff --git a/nonebot_plugin_marshoai/plugin/__init__.py b/nonebot_plugin_marshoai/plugin/__init__.py index 232f1a16..bffca6f8 100644 --- a/nonebot_plugin_marshoai/plugin/__init__.py +++ b/nonebot_plugin_marshoai/plugin/__init__.py @@ -8,4 +8,4 @@ from .load import * from .models import * from .utils import * -#logger.opt(colors=True).info("MarshoAI 插件功能开发中,用户请忽略相关日志") +# logger.opt(colors=True).info("MarshoAI 插件功能开发中,用户请忽略相关日志")