fix(docs): adapted vuepress2 beta51 (#2270)

pull/2286/head
Fatpandac 2 years ago committed by GitHub
parent 6762a22f84
commit 298e3db559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,7 +1,6 @@
import oldContributorsData from "./oldContributorsData.json"; import oldContributorsData from "./oldContributorsData.json";
import { usePageData } from "@vuepress/client"; import { usePageData, defineClientConfig } from "@vuepress/client";
import { defineClientConfig } from "@vuepress/client";
import CountTo from "vue-count-to/src/vue-countTo.vue"; import CountTo from "vue-count-to/src/vue-countTo.vue";
const addOldDocsContributors = () => { const addOldDocsContributors = () => {

@ -1,18 +1,17 @@
const { localTheme } = require("./theme/index"); import { localTheme } from "./theme/index";
const { loadVersionPlugin } = require("./plugins/vuepress-plugin-loadVersion"); import { loadVersionPlugin } from "./plugins/vuepress-plugin-loadVersion";
import { head, navbarEN, navbarZH, sidebarEN, sidebarZH } from "./configs";
const { import { activeHeaderLinksPlugin } from "@vuepress/plugin-active-header-links";
activeHeaderLinksPlugin, import { copyCodePlugin } from "vuepress-plugin-copy-code2";
} = require("@vuepress/plugin-active-header-links"); import { docsearchPlugin } from "@vuepress/plugin-docsearch";
const { docsearchPlugin } = require("@vuepress/plugin-docsearch"); import { redirectPlugin } from "vuepress-plugin-redirect";
const { copyCodePlugin } = require("vuepress-plugin-copy-code2"); import { defineUserConfig } from "vuepress";
const { redirectPlugin } = require("vuepress-plugin-redirect");
const { searchPlugin } = require("@vuepress/plugin-search");
module.exports = { export default defineUserConfig({
title: "arthas", title: "arthas",
description: "arthas user document", description: "arthas user document",
head: require("./configs/head"), head,
locales: { locales: {
"/": { "/": {
lang: "zh-CN", lang: "zh-CN",
@ -31,6 +30,9 @@ module.exports = {
repo: "alibaba/arthas", repo: "alibaba/arthas",
docsDir: "site/docs", docsDir: "site/docs",
docsBranch: "master", docsBranch: "master",
themePlugins: {
activeHeaderLinks: false,
},
locales: { locales: {
"/": { "/": {
@ -51,20 +53,19 @@ module.exports = {
"这是一个 404 页面", "这是一个 404 页面",
"看起来我们进入了错误的链接", "看起来我们进入了错误的链接",
], ],
backToHome: "返回首页",
openInNewWindow: "在新窗口打开", openInNewWindow: "在新窗口打开",
toggleColorMode: "切换颜色模式", toggleColorMode: "切换颜色模式",
toggleSidebar: "切换侧边栏", toggleSidebar: "切换侧边栏",
navbar: require("./configs/navbar/zh"), navbar: navbarZH,
sidebar: require("./configs/sidebar/zh"), sidebar: sidebarZH,
sidebarDepth: 0, sidebarDepth: 0,
}, },
"/en/": { "/en/": {
selectLanguageName: "English", selectLanguageName: "English",
selectLanguageText: "Languages", selectLanguageText: "Languages",
editLinkText: "Edit this page on GitHub", editLinkText: "Edit this page on GitHub",
navbar: require("./configs/navbar/en"), navbar: navbarEN,
sidebar: require("./configs/sidebar/en"), sidebar: sidebarEN,
sidebarDepth: 0, sidebarDepth: 0,
}, },
}, },
@ -82,16 +83,6 @@ module.exports = {
}, },
}, },
}), }),
searchPlugin({
locales: {
"/": {
placeholder: "搜索文档",
},
"/en/": {
placeholder: "Search Docs",
},
},
}),
redirectPlugin({ redirectPlugin({
config: (app) => { config: (app) => {
const redirects = Object.fromEntries( const redirects = Object.fromEntries(
@ -165,4 +156,4 @@ module.exports = {
// Local plugin // Local plugin
loadVersionPlugin(), loadVersionPlugin(),
], ],
}; });

@ -1,4 +1,4 @@
module.exports = [ export const head = [
["link", { rel: "icon", href: "/images/favicon.ico" }], ["link", { rel: "icon", href: "/images/favicon.ico" }],
[ [
"meta", "meta",

@ -0,0 +1,3 @@
export * from "./navbar";
export * from "./sidebar";
export * from "./head";

@ -1,4 +1,4 @@
module.exports = [ export const navbarEN = [
{ {
text: "HOME", text: "HOME",
link: "/en/", link: "/en/",

@ -0,0 +1,2 @@
export * from "./zh";
export * from "./en";

@ -1,4 +1,4 @@
module.exports = [ export const navbarZH = [
{ {
text: "首页", text: "首页",
link: "/", link: "/",

@ -1,4 +1,4 @@
module.exports = { export const sidebarEN = {
"/en/doc": [ "/en/doc": [
{ {
text: "DOCS", text: "DOCS",

@ -0,0 +1,2 @@
export * from "./zh";
export * from "./en";

@ -1,4 +1,4 @@
module.exports = { export const sidebarZH = {
"/doc/": [ "/doc/": [
{ {
text: "文档", text: "文档",

@ -1,10 +1,10 @@
const fs = require("fs"); import { readFileSync } from "fs";
const fetch = require("node-fetch"); import fetch from "node-fetch";
const convert = require("xml-js"); import { xml2js } from "xml-js";
exports.loadVersionPlugin = () => { export function loadVersionPlugin() {
const data = fs.readFileSync("../pom.xml"); const data = readFileSync("../pom.xml");
const pom = convert.xml2js(data.toString(), { compact: true }); const pom = xml2js(data.toString(), { compact: true });
const getVersionByMaven = async () => { const getVersionByMaven = async () => {
return await fetch( return await fetch(
@ -26,4 +26,4 @@ exports.loadVersionPlugin = () => {
app.pages.map((page) => (page.data.version = version)); app.pages.map((page) => (page.data.version = version));
}, },
}; };
}; }

@ -7,7 +7,7 @@
</template> </template>
<script setup> <script setup>
import { useThemeLocaleData } from "@vuepress/theme-default/lib/client/composables"; import { useThemeLocaleData } from "@vuepress/plugin-theme-data/client";
const props = defineProps({ const props = defineProps({
comp: { comp: {

@ -10,7 +10,7 @@ import {
} from "@vuepress/client"; } from "@vuepress/client";
import { isArray } from "@vuepress/shared"; import { isArray } from "@vuepress/shared";
import { computed, h } from "vue"; import { computed, h } from "vue";
import { useDarkMode } from "@vuepress/theme-default/lib/client/composables"; import { useDarkMode } from "@vuepress/theme-default/client";
const frontmatter = usePageFrontmatter(); const frontmatter = usePageFrontmatter();
const siteLocale = useSiteLocaleData(); const siteLocale = useSiteLocaleData();

@ -7,10 +7,8 @@ import {
withBase, withBase,
} from "@vuepress/client"; } from "@vuepress/client";
import { computed, h, ref } from "vue"; import { computed, h, ref } from "vue";
import { import { useThemeLocaleData } from "@vuepress/plugin-theme-data/client";
useDarkMode, import { useDarkMode } from "@vuepress/theme-default/client";
useThemeLocaleData,
} from "@vuepress/theme-default/lib/client";
const pageData = usePageData(); const pageData = usePageData();
const isDarkMode = useDarkMode(); const isDarkMode = useDarkMode();

@ -51,7 +51,7 @@ SRC: https://github.com/xugaoyi/vuepress-theme-vdoing/blob/master/vdoing/compone
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { onMounted, watch, ref } from "vue"; import { onMounted, watch, ref } from "vue";
import { usePageData } from "@vuepress/client"; import { usePageData } from "@vuepress/client";
import { useThemeLocaleData } from "@vuepress/theme-default/lib/client/composables/useThemeData"; import { useThemeLocaleData } from "@vuepress/plugin-theme-data/client";
const pages = usePageData(); const pages = usePageData();
const theme = useThemeLocaleData(); const theme = useThemeLocaleData();

@ -1,7 +1,9 @@
const { defaultTheme } = require("@vuepress/theme-default"); import { defaultTheme } from "@vuepress/theme-default";
const { path } = require("@vuepress/utils"); import { getDirname, path } from "@vuepress/utils";
exports.localTheme = (options) => { const __dirname = getDirname(import.meta.url);
export function localTheme(options) {
return { return {
name: "vuepress-theme-arthas", name: "vuepress-theme-arthas",
extends: defaultTheme(options), extends: defaultTheme(options),
@ -20,4 +22,4 @@ exports.localTheme = (options) => {
), ),
}, },
}; };
}; }

3635
site/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,8 +1,7 @@
{ {
"name": "site", "name": "site",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "Arthas user documentation site",
"main": "index.js",
"scripts": { "scripts": {
"docs:dev": "vuepress dev docs", "docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs", "docs:build": "vuepress build docs",
@ -11,16 +10,16 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@vuepress/plugin-active-header-links": "^2.0.0-beta.49", "@vuepress/plugin-active-header-links": "^2.0.0-beta.51",
"@vuepress/plugin-docsearch": "^2.0.0-beta.49", "@vuepress/plugin-docsearch": "^2.0.0-beta.51",
"@vuepress/plugin-search": "^2.0.0-beta.48", "@vuepress/plugin-theme-data": "^2.0.0-beta.51",
"prettier": "2.7.1", "prettier": "2.7.1",
"vuepress": "^2.0.0-beta.48", "vuepress": "^2.0.0-beta.51",
"vuepress-plugin-copy-code2": "^2.0.0-beta.84", "vuepress-plugin-copy-code2": "^2.0.0-beta.97",
"vuepress-plugin-redirect": "^2.0.0-beta.86" "vuepress-plugin-redirect": "^2.0.0-beta.97"
}, },
"dependencies": { "dependencies": {
"node-fetch": "^2.6.7", "node-fetch": "^3.2.10",
"vue-count-to": "^1.0.13", "vue-count-to": "^1.0.13",
"xml-js": "^1.6.11" "xml-js": "^1.6.11"
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save