87 lines
2.4 KiB
TypeScript
Raw Normal View History

2024-01-21 00:49:42 +08:00
import { viteBundler } from "@vuepress/bundler-vite";
import { webpackBundler } from "@vuepress/bundler-webpack";
2024-01-26 05:07:42 +08:00
// import { UserConfig, defineUserConfig } from "@vuepress/cli";
import { UserConfig, defineUserConfig } from "vuepress/cli";
2024-01-21 00:49:42 +08:00
import { searchPlugin } from "@vuepress/plugin-search";
import markdownItFootnote from "markdown-it-footnote";
2024-01-26 05:07:42 +08:00
import theme from './theme.js'
import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
import process from 'node:process'
// import { getDirname, path } from '@vuepress/utils'
import { getDirname, path } from 'vuepress/utils'
import { MermaidPlugin } from './plugins/mermaid/node/mermaid'
import i18nPlugin from "vuepress-plugin-i18n";
2021-04-06 23:47:32 +08:00
2024-01-26 05:07:42 +08:00
const __dirname = getDirname(import.meta.url)
console.log('>>> __dirname -> ', __dirname)
2021-05-03 12:57:54 +08:00
const isProduction = process.env.NODE_ENV === "production";
2021-09-15 18:28:06 +08:00
const forMainRepo = process.env.XRAY_DOCS_MAIN_REPO === "true";
const useVite = process.env.XRAY_DOCS_USE_VITE === "true";
console.log("base:", forMainRepo ? "/" : "/Xray-docs-next/");
console.log(
"bundler:",
isProduction && !useVite ? "@vuepress/webpack" : "@vuepress/vite"
);
2021-05-03 12:57:54 +08:00
2024-01-21 00:49:42 +08:00
export default defineUserConfig(<UserConfig>{
2021-05-03 12:57:54 +08:00
plugins: [
i18nPlugin({
updatedTime: "git",
translationGuide: "https://github.com/XTLS/Xray-docs-next",
locales: {
en: {
lang: "en-US",
untranslated: {
title: "Untranslated"
},
outdated: {
title: "Outdated"
}
}
}
}),
2024-01-21 00:49:42 +08:00
searchPlugin({
locales: {
"/": {
placeholder: "搜索",
2021-05-03 12:57:54 +08:00
},
},
2024-01-21 00:49:42 +08:00
}),
2024-01-26 05:07:42 +08:00
registerComponentsPlugin({
componentsDir: path.resolve(__dirname, './theme/components'),
}),
2021-05-03 12:57:54 +08:00
],
2021-09-15 18:28:06 +08:00
base: forMainRepo ? "/" : "/Xray-docs-next/",
2021-04-06 23:47:32 +08:00
locales: {
"/": {
lang: "zh-CN",
title: "Project X",
description: "Xray 官方文档",
},
2021-05-26 20:25:44 +08:00
"/en/": {
2021-05-26 19:05:53 +08:00
lang: "en-US",
title: "Project X",
description: "Official document of Xray",
2021-05-26 19:32:52 +08:00
},
"/ru/": {
lang: "ru-RU",
title: "Project X",
description: "Официальная документация Xray",
},
2021-04-06 23:47:32 +08:00
},
2024-01-26 05:07:42 +08:00
theme,
head: [["link", { rel: "icon", href: `/logo.png` }]],
2021-04-06 23:47:32 +08:00
markdown: {
toc: {
level: [2],
},
},
extendsMarkdown: (md) => {
2024-01-21 00:49:42 +08:00
md.use(markdownItFootnote);
md.use(MermaidPlugin);
2021-04-06 23:47:32 +08:00
},
2024-01-21 00:49:42 +08:00
bundler:
process.env.DOCS_BUNDLER === "webpack" ? webpackBundler() : viteBundler(),
2021-04-06 23:47:32 +08:00
});