diff --git a/site/docs/.vuepress/client.js b/site/docs/.vuepress/client.js index 3757a9c46..4d667f35f 100644 --- a/site/docs/.vuepress/client.js +++ b/site/docs/.vuepress/client.js @@ -1,7 +1,6 @@ import oldContributorsData from "./oldContributorsData.json"; -import { usePageData } from "@vuepress/client"; -import { defineClientConfig } from "@vuepress/client"; +import { usePageData, defineClientConfig } from "@vuepress/client"; import CountTo from "vue-count-to/src/vue-countTo.vue"; const addOldDocsContributors = () => { diff --git a/site/docs/.vuepress/config.js b/site/docs/.vuepress/config.js index e40adb331..50ab0efb4 100644 --- a/site/docs/.vuepress/config.js +++ b/site/docs/.vuepress/config.js @@ -1,18 +1,17 @@ -const { localTheme } = require("./theme/index"); -const { loadVersionPlugin } = require("./plugins/vuepress-plugin-loadVersion"); +import { localTheme } from "./theme/index"; +import { loadVersionPlugin } from "./plugins/vuepress-plugin-loadVersion"; +import { head, navbarEN, navbarZH, sidebarEN, sidebarZH } from "./configs"; -const { - activeHeaderLinksPlugin, -} = require("@vuepress/plugin-active-header-links"); -const { docsearchPlugin } = require("@vuepress/plugin-docsearch"); -const { copyCodePlugin } = require("vuepress-plugin-copy-code2"); -const { redirectPlugin } = require("vuepress-plugin-redirect"); -const { searchPlugin } = require("@vuepress/plugin-search"); +import { activeHeaderLinksPlugin } from "@vuepress/plugin-active-header-links"; +import { copyCodePlugin } from "vuepress-plugin-copy-code2"; +import { docsearchPlugin } from "@vuepress/plugin-docsearch"; +import { redirectPlugin } from "vuepress-plugin-redirect"; +import { defineUserConfig } from "vuepress"; -module.exports = { +export default defineUserConfig({ title: "arthas", description: "arthas user document", - head: require("./configs/head"), + head, locales: { "/": { lang: "zh-CN", @@ -31,6 +30,9 @@ module.exports = { repo: "alibaba/arthas", docsDir: "site/docs", docsBranch: "master", + themePlugins: { + activeHeaderLinks: false, + }, locales: { "/": { @@ -51,20 +53,19 @@ module.exports = { "这是一个 404 页面", "看起来我们进入了错误的链接", ], - backToHome: "返回首页", openInNewWindow: "在新窗口打开", toggleColorMode: "切换颜色模式", toggleSidebar: "切换侧边栏", - navbar: require("./configs/navbar/zh"), - sidebar: require("./configs/sidebar/zh"), + navbar: navbarZH, + sidebar: sidebarZH, sidebarDepth: 0, }, "/en/": { selectLanguageName: "English", selectLanguageText: "Languages", editLinkText: "Edit this page on GitHub", - navbar: require("./configs/navbar/en"), - sidebar: require("./configs/sidebar/en"), + navbar: navbarEN, + sidebar: sidebarEN, sidebarDepth: 0, }, }, @@ -82,16 +83,6 @@ module.exports = { }, }, }), - searchPlugin({ - locales: { - "/": { - placeholder: "搜索文档", - }, - "/en/": { - placeholder: "Search Docs", - }, - }, - }), redirectPlugin({ config: (app) => { const redirects = Object.fromEntries( @@ -165,4 +156,4 @@ module.exports = { // Local plugin loadVersionPlugin(), ], -}; +}); diff --git a/site/docs/.vuepress/configs/head.js b/site/docs/.vuepress/configs/head/head.js similarity index 99% rename from site/docs/.vuepress/configs/head.js rename to site/docs/.vuepress/configs/head/head.js index 86dde89cb..f9d53f9aa 100644 --- a/site/docs/.vuepress/configs/head.js +++ b/site/docs/.vuepress/configs/head/head.js @@ -1,4 +1,4 @@ -module.exports = [ +export const head = [ ["link", { rel: "icon", href: "/images/favicon.ico" }], [ "meta", diff --git a/site/docs/.vuepress/configs/head/index.js b/site/docs/.vuepress/configs/head/index.js new file mode 100644 index 000000000..3f0f289bb --- /dev/null +++ b/site/docs/.vuepress/configs/head/index.js @@ -0,0 +1 @@ +export * from "./head"; diff --git a/site/docs/.vuepress/configs/index.js b/site/docs/.vuepress/configs/index.js new file mode 100644 index 000000000..e8b338f40 --- /dev/null +++ b/site/docs/.vuepress/configs/index.js @@ -0,0 +1,3 @@ +export * from "./navbar"; +export * from "./sidebar"; +export * from "./head"; diff --git a/site/docs/.vuepress/configs/navbar/en.js b/site/docs/.vuepress/configs/navbar/en.js index e4df06349..2487d02c7 100644 --- a/site/docs/.vuepress/configs/navbar/en.js +++ b/site/docs/.vuepress/configs/navbar/en.js @@ -1,4 +1,4 @@ -module.exports = [ +export const navbarEN = [ { text: "HOME", link: "/en/", diff --git a/site/docs/.vuepress/configs/navbar/index.js b/site/docs/.vuepress/configs/navbar/index.js new file mode 100644 index 000000000..273120183 --- /dev/null +++ b/site/docs/.vuepress/configs/navbar/index.js @@ -0,0 +1,2 @@ +export * from "./zh"; +export * from "./en"; diff --git a/site/docs/.vuepress/configs/navbar/zh.js b/site/docs/.vuepress/configs/navbar/zh.js index ae272516f..27760c2b5 100644 --- a/site/docs/.vuepress/configs/navbar/zh.js +++ b/site/docs/.vuepress/configs/navbar/zh.js @@ -1,4 +1,4 @@ -module.exports = [ +export const navbarZH = [ { text: "首页", link: "/", diff --git a/site/docs/.vuepress/configs/sidebar/en.js b/site/docs/.vuepress/configs/sidebar/en.js index 228b47d27..3668706fc 100644 --- a/site/docs/.vuepress/configs/sidebar/en.js +++ b/site/docs/.vuepress/configs/sidebar/en.js @@ -1,4 +1,4 @@ -module.exports = { +export const sidebarEN = { "/en/doc": [ { text: "DOCS", diff --git a/site/docs/.vuepress/configs/sidebar/index.js b/site/docs/.vuepress/configs/sidebar/index.js new file mode 100644 index 000000000..273120183 --- /dev/null +++ b/site/docs/.vuepress/configs/sidebar/index.js @@ -0,0 +1,2 @@ +export * from "./zh"; +export * from "./en"; diff --git a/site/docs/.vuepress/configs/sidebar/zh.js b/site/docs/.vuepress/configs/sidebar/zh.js index 6b990fa64..ce16e94f1 100644 --- a/site/docs/.vuepress/configs/sidebar/zh.js +++ b/site/docs/.vuepress/configs/sidebar/zh.js @@ -1,4 +1,4 @@ -module.exports = { +export const sidebarZH = { "/doc/": [ { text: "文档", diff --git a/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js b/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js index af38c04fb..53d1c9ce1 100644 --- a/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js +++ b/site/docs/.vuepress/plugins/vuepress-plugin-loadVersion/index.js @@ -1,10 +1,10 @@ -const fs = require("fs"); -const fetch = require("node-fetch"); -const convert = require("xml-js"); +import { readFileSync } from "fs"; +import fetch from "node-fetch"; +import { xml2js } from "xml-js"; -exports.loadVersionPlugin = () => { - const data = fs.readFileSync("../pom.xml"); - const pom = convert.xml2js(data.toString(), { compact: true }); +export function loadVersionPlugin() { + const data = readFileSync("../pom.xml"); + const pom = xml2js(data.toString(), { compact: true }); const getVersionByMaven = async () => { return await fetch( @@ -26,4 +26,4 @@ exports.loadVersionPlugin = () => { app.pages.map((page) => (page.data.version = version)); }, }; -}; +} diff --git a/site/docs/.vuepress/theme/components/Badge.vue b/site/docs/.vuepress/theme/components/Badge.vue index 9ed37462a..055841bf6 100644 --- a/site/docs/.vuepress/theme/components/Badge.vue +++ b/site/docs/.vuepress/theme/components/Badge.vue @@ -7,7 +7,7 @@