mbcp/docs/.vitepress/config/common.ts

85 lines
2.5 KiB
TypeScript
Raw Normal View History

2024-08-28 11:56:19 +08:00
import {defineConfig} from 'vitepress'
2024-08-29 19:00:01 +08:00
import {generateSidebar} from 'vitepress-sidebar';
import {zh} from "./zh";
import {en} from "./en";
import {ja} from "./ja";
import {zht} from "./zht";
2024-08-28 11:38:46 +08:00
2024-08-29 19:00:01 +08:00
let defaultLocale = 'zh';
const commonSidebarOptions = {
collapsed: true,
convertSameNameSubFileToGroupIndexPage: true,
useTitleFromFrontmatter: true,
useTitleFromFileHeading: true,
2024-08-30 14:29:58 +08:00
useFolderTitleFromIndexFile: true,
useFolderLinkFromIndexFile: true,
2024-08-29 19:00:01 +08:00
includeFolderIndexFile: true,
2024-08-30 17:56:01 +08:00
rootGroupText: 'MBCP',
2024-08-29 19:00:01 +08:00
}
2024-08-30 17:56:01 +08:00
/**
* Generate sidebar config
* multiple languages and sections
* @returns {any[]}
*/
function generateSidebarConfig(): any[] {
let sections = ["api", "refer", "guide"]
let languages = ['zh', 'en', 'ja', 'zht']
let ret = []
for (let language of languages) {
for (let section of sections) {
if (language === defaultLocale) {
ret.push({
basePath: `/${section}/`,
scanStartPath: `${language}/${section}`,
resolvePath: `/${section}/`,
...commonSidebarOptions
})
} else {
ret.push({
basePath: `/${language}/${section}/`,
scanStartPath: `${language}/${section}`,
resolvePath: `/${language}/${section}/`,
...commonSidebarOptions
})
}
}
}
return ret
}
console.log(generateSidebarConfig())
2024-08-28 11:38:46 +08:00
export const common = defineConfig({
2024-08-31 06:06:32 +08:00
head: [
2024-08-31 07:31:06 +08:00
['link', {rel: 'icon', type: 'image/svg+xml', href: '/mbcp-logo.svg'}],
['link', {rel: 'stylesheet', href: 'https://fonts.font.im/css?family=Cousine:400,400i,700,700i|Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i'}],
2024-08-31 06:06:32 +08:00
],
2024-08-29 19:00:01 +08:00
markdown: {
math: true
},
rewrites: {
[`${defaultLocale}/:rest*`]: ":rest*",
2024-08-28 12:02:30 +08:00
},
2024-08-28 11:38:46 +08:00
themeConfig: {
2024-08-31 06:06:32 +08:00
logo: '/mbcp-logo.svg',
2024-08-29 19:00:01 +08:00
sidebar: generateSidebar(
[
2024-08-30 17:56:01 +08:00
...generateSidebarConfig()
2024-08-29 19:00:01 +08:00
]
),
2024-08-28 11:38:46 +08:00
socialLinks: [
{icon: 'github', link: 'https://github.com/snowykami/mbcp'}
2024-08-29 19:00:01 +08:00
],
2024-08-30 15:09:17 +08:00
outline: [2, 6]
2024-08-30 14:29:58 +08:00
},
sitemap: {
hostname: 'https://mbcp.sfkm.me'
2024-08-29 19:00:01 +08:00
},
locales: {
root: {label: "简体中文", ...zh},
en: {label: "English", ...en},
ja: {label: "日本語", ...ja},
zht: {label: "繁體中文", ...zht},
2024-08-28 11:38:46 +08:00
},
})