mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-01-26 18:12:47 +08:00
✨ 更新配置,添加主题配置和编辑链接功能,支持多语言文档编辑
This commit is contained in:
parent
721904d4c3
commit
575993ebc4
@ -43,3 +43,39 @@ export function generateSidebarConfig(): VitePressSidebarOptions[] {
|
|||||||
}
|
}
|
||||||
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
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
getOutLine: (label: string): { label: string; level: [number, number]; } => {
|
||||||
|
return {
|
||||||
|
label: label,
|
||||||
|
level: [2, 6]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
copyright: 'Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved'
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import {defineConfig} from 'vitepress'
|
import {defineConfig} from 'vitepress'
|
||||||
|
import { ThemeConfig } from './common'
|
||||||
|
|
||||||
export const en = defineConfig({
|
export const en = defineConfig({
|
||||||
lang: "en-US",
|
lang: "en-US",
|
||||||
@ -14,6 +15,7 @@ export const en = defineConfig({
|
|||||||
{text: 'Usage', link: '/en/start/install'},
|
{text: 'Usage', link: '/en/start/install'},
|
||||||
{text: 'Develop', link: '/en/dev/extension'},
|
{text: 'Develop', link: '/en/dev/extension'},
|
||||||
],
|
],
|
||||||
|
editLink: ThemeConfig.getEditLink('Edit this page'),
|
||||||
langMenuLabel: 'Language',
|
langMenuLabel: 'Language',
|
||||||
returnToTopLabel: 'To top',
|
returnToTopLabel: 'To top',
|
||||||
sidebarMenuLabel: 'Option',
|
sidebarMenuLabel: 'Option',
|
||||||
|
@ -36,4 +36,5 @@ export default defineConfig({
|
|||||||
en: { label: "English", ...en },
|
en: { label: "English", ...en },
|
||||||
ja: { label: "日本語", ...ja },
|
ja: { label: "日本語", ...ja },
|
||||||
},
|
},
|
||||||
|
lastUpdated: true,
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {defineConfig} from 'vitepress'
|
import {defineConfig} from 'vitepress'
|
||||||
|
import { ThemeConfig } from './common'
|
||||||
|
|
||||||
export const ja = defineConfig({
|
export const ja = defineConfig({
|
||||||
lang: "ja-JP",
|
lang: "ja-JP",
|
||||||
@ -14,6 +15,7 @@ export const ja = defineConfig({
|
|||||||
{text: '使用方法', link: '/ja/start/install'},
|
{text: '使用方法', link: '/ja/start/install'},
|
||||||
{text: '開発', link: '/ja/dev/extension'},
|
{text: '開発', link: '/ja/dev/extension'},
|
||||||
],
|
],
|
||||||
|
editLink: ThemeConfig.getEditLink('このページを編集'),
|
||||||
langMenuLabel: '言語',
|
langMenuLabel: '言語',
|
||||||
returnToTopLabel: 'トップへ戻る',
|
returnToTopLabel: 'トップへ戻る',
|
||||||
sidebarMenuLabel: 'オプション',
|
sidebarMenuLabel: 'オプション',
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {defineConfig} from 'vitepress'
|
import {defineConfig} from 'vitepress'
|
||||||
|
import { ThemeConfig } from './common'
|
||||||
|
|
||||||
export const zh = defineConfig({
|
export const zh = defineConfig({
|
||||||
lang: "zh-Hans",
|
lang: "zh-Hans",
|
||||||
@ -14,6 +15,7 @@ export const zh = defineConfig({
|
|||||||
{text: '使用', link: '/start/install'},
|
{text: '使用', link: '/start/install'},
|
||||||
{text: '开发', link: '/dev/extension'},
|
{text: '开发', link: '/dev/extension'},
|
||||||
],
|
],
|
||||||
|
editLink: ThemeConfig.getEditLink('编辑此页面'),
|
||||||
langMenuLabel: '语言',
|
langMenuLabel: '语言',
|
||||||
returnToTopLabel: '返回顶部',
|
returnToTopLabel: '返回顶部',
|
||||||
sidebarMenuLabel: '菜单',
|
sidebarMenuLabel: '菜单',
|
||||||
|
@ -8,4 +8,4 @@ from .load import *
|
|||||||
from .models import *
|
from .models import *
|
||||||
from .utils import *
|
from .utils import *
|
||||||
|
|
||||||
#logger.opt(colors=True).info("<y>MarshoAI 插件功能开发中,用户请忽略相关日志</y>")
|
# logger.opt(colors=True).info("<y>MarshoAI 插件功能开发中,用户请忽略相关日志</y>")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user