mirror of
https://github.com/XTLS/Xray-docs-next.git
synced 2025-01-19 17:21:41 +03:00
Fix: theme local options
This commit is contained in:
parent
5d09bc4d76
commit
f1671b156f
@ -23,7 +23,6 @@ export default defineUserConfig<DefaultThemeOptions>({
|
|||||||
editLinks: true,
|
editLinks: true,
|
||||||
editLinkText: "帮助我们改善此页面!",
|
editLinkText: "帮助我们改善此页面!",
|
||||||
enableToggle: true,
|
enableToggle: true,
|
||||||
ToggleText: "切换主题",
|
|
||||||
navbar: [
|
navbar: [
|
||||||
{ text: "首页", link: "/" },
|
{ text: "首页", link: "/" },
|
||||||
{ text: "大史记", link: "/about/news.md" },
|
{ text: "大史记", link: "/about/news.md" },
|
||||||
@ -159,6 +158,11 @@ export default defineUserConfig<DefaultThemeOptions>({
|
|||||||
themePlugins: {
|
themePlugins: {
|
||||||
git: process.env.NODE_ENV === "production",
|
git: process.env.NODE_ENV === "production",
|
||||||
},
|
},
|
||||||
|
locales: {
|
||||||
|
"/": {
|
||||||
|
ToggleText: "切换主题",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
markdown: {
|
markdown: {
|
||||||
toc: {
|
toc: {
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import { ThemeOptions } from "../index";
|
import { useThemeLocaleData } from "@vuepress/plugin-theme-data/lib/composables";
|
||||||
declare const __LAYOUT__OPTIONS__: ThemeOptions;
|
import { ToggleOptions } from "../types";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
data() {
|
data() {
|
||||||
@ -21,8 +21,9 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.enable = __LAYOUT__OPTIONS__.enableToggle;
|
const option = useThemeLocaleData<ToggleOptions>();
|
||||||
this.text = __LAYOUT__OPTIONS__.ToggleText;
|
this.enable = option.value.enableToggle;
|
||||||
|
this.text = option.value.ToggleText;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleTheme() {
|
toggleTheme() {
|
||||||
|
@ -1,21 +1,13 @@
|
|||||||
import { path } from "@vuepress/utils";
|
import { path } from "@vuepress/utils";
|
||||||
import { Theme } from "@vuepress/core";
|
import { Theme } from "@vuepress/core";
|
||||||
|
|
||||||
export interface ThemeOptions {
|
export const docsPlugin: Theme = (options, app) => {
|
||||||
enableToggle?: boolean;
|
|
||||||
ToggleText?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const docsPlugin: Theme<ThemeOptions> = (options, app) => {
|
|
||||||
return {
|
return {
|
||||||
name: "xray-docs-theme",
|
name: "xray-docs-theme",
|
||||||
extends: "@vuepress/theme-default",
|
extends: "@vuepress/theme-default",
|
||||||
layouts: {
|
layouts: {
|
||||||
Layout: path.resolve(__dirname, "layouts/Layout.vue"),
|
Layout: path.resolve(__dirname, "layouts/Layout.vue"),
|
||||||
},
|
},
|
||||||
define: {
|
|
||||||
__LAYOUT__OPTIONS__: options,
|
|
||||||
},
|
|
||||||
clientAppEnhanceFiles: path.resolve(__dirname, "clientAppEnhance.ts"),
|
clientAppEnhanceFiles: path.resolve(__dirname, "clientAppEnhance.ts"),
|
||||||
plugins: [["@vuepress/plugin-palette", { preset: "sass" }]],
|
plugins: [["@vuepress/plugin-palette", { preset: "sass" }]],
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,3 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass">
|
|
||||||
//@import "../styles/default/index.scss"
|
|
||||||
</style>
|
|
||||||
|
1
docs/.vuepress/theme/types/index.ts
Normal file
1
docs/.vuepress/theme/types/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./toggle";
|
4
docs/.vuepress/theme/types/toggle.ts
Normal file
4
docs/.vuepress/theme/types/toggle.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface ToggleOptions {
|
||||||
|
enableToggle?: boolean;
|
||||||
|
ToggleText?: string;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user