迁移准备

This commit is contained in:
Meow
2025-12-21 22:14:50 -05:00
committed by yuhan6665
parent 3acefe8200
commit bb47a72bc8
32 changed files with 0 additions and 0 deletions
-84
View File
@@ -1,84 +0,0 @@
import { viteBundler } from "@vuepress/bundler-vite";
import { webpackBundler } from "@vuepress/bundler-webpack";
// import { UserConfig, defineUserConfig } from "@vuepress/cli";
import { UserConfig, defineUserConfig } from "vuepress/cli";
import { searchPlugin } from "@vuepress/plugin-search";
import markdownItFootnote from "markdown-it-footnote";
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";
const __dirname = getDirname(import.meta.url);
console.log(">>> __dirname -> ", __dirname);
const isProduction = process.env.NODE_ENV === "production";
const useVite = process.env.XRAY_DOCS_USE_VITE === "true";
console.log(
"bundler:",
isProduction && !useVite ? "@vuepress/webpack" : "@vuepress/vite",
);
export default defineUserConfig(<UserConfig>{
plugins: [
i18nPlugin({
updatedTime: "git",
translationGuide: "https://github.com/XTLS/Xray-docs-next",
locales: {
en: {
lang: "en-US",
untranslated: {
title: "Untranslated",
},
outdated: {
title: "Outdated",
},
},
},
}),
searchPlugin({
locales: {
"/": {
placeholder: "搜索",
},
},
}),
registerComponentsPlugin({
componentsDir: path.resolve(__dirname, "./theme/components"),
}),
],
base: "/",
locales: {
"/": {
lang: "zh-CN",
title: "Project X",
description: "Xray 官方文档",
},
"/en/": {
lang: "en-US",
title: "Project X",
description: "Official document of Xray",
},
"/ru/": {
lang: "ru-RU",
title: "Project X",
description: "Официальная документация Xray",
},
},
theme,
head: [["link", { rel: "icon", href: `/logo.png` }]],
markdown: {
toc: {
level: [2],
},
},
extendsMarkdown: (md) => {
md.use(markdownItFootnote);
md.use(MermaidPlugin);
},
bundler:
process.env.DOCS_BUNDLER === "webpack" ? webpackBundler() : viteBundler(),
});
-3
View File
@@ -1,3 +0,0 @@
// export * from './head'
export * from "./navbar/index.js";
export * from "./sidebar/index.js";
-10
View File
@@ -1,10 +0,0 @@
import { NavbarConfig } from "@vuepress/theme-default";
// TODO: translation
export const navbarEn: NavbarConfig = [
{ text: "Homepage", link: "/en" },
{ text: "The Great Chronicles", link: "/en/about/news.md" },
{ text: "Config Reference", link: "/en/config/" },
{ text: "Developer Guide", link: "/en/development/" },
{ text: "Quick Start", link: "/en/document/" },
];
-3
View File
@@ -1,3 +0,0 @@
export * from "./en.js";
export * from "./zh.js";
export * from "./ru.js";
-9
View File
@@ -1,9 +0,0 @@
import { NavbarConfig } from "@vuepress/theme-default";
export const navbarRu: NavbarConfig = [
{ text: "Главная", link: "/ru" },
{ text: "История сайта", link: "/ru/about/news.md" },
{ text: "Справочник по конфигурации", link: "/ru/config/" },
{ text: "Руководство разработчика", link: "/ru/development/" },
{ text: "Быстрый старт", link: "/ru/document/" },
];
-9
View File
@@ -1,9 +0,0 @@
import { NavbarConfig } from "@vuepress/theme-default";
export const navbarZh: NavbarConfig = [
{ text: "首页", link: "/" },
{ text: "大史记", link: "/about/news.md" },
{ text: "配置指南", link: "/config/" },
{ text: "开发指南", link: "/development/" },
{ text: "使用指南", link: "/document/" },
];
-147
View File
@@ -1,147 +0,0 @@
import type { SidebarConfig } from "@vuepress/theme-default";
export const sidebarEn: SidebarConfig = {
"/en/config/": [
{
text: "feature",
children: [
"/en/config/features/xtls.md",
"/en/config/features/fallback.md",
"/en/config/features/browser_dialer.md",
"/en/config/features/env.md",
"/en/config/features/multiple.md",
],
},
{
text: "config",
children: [
"/en/config/README.md",
"/en/config/log.md",
"/en/config/api.md",
"/en/config/dns.md",
"/en/config/fakedns.md",
"/en/config/inbound.md",
"/en/config/outbound.md",
"/en/config/policy.md",
"/en/config/reverse.md",
"/en/config/routing.md",
"/en/config/stats.md",
"/en/config/transport.md",
"/en/config/metrics.md",
"/en/config/observatory.md",
],
},
{
text: "inbound",
children: [
"/en/config/inbounds/dokodemo.md",
"/en/config/inbounds/http.md",
"/en/config/inbounds/shadowsocks.md",
"/en/config/inbounds/socks.md",
"/en/config/inbounds/trojan.md",
"/en/config/inbounds/vless.md",
"/en/config/inbounds/vmess.md",
"/en/config/inbounds/wireguard.md",
],
},
{
text: "outbound",
children: [
"/en/config/outbounds/blackhole.md",
"/en/config/outbounds/dns.md",
"/en/config/outbounds/freedom.md",
"/en/config/outbounds/http.md",
"/en/config/outbounds/loopback.md",
"/en/config/outbounds/shadowsocks.md",
"/en/config/outbounds/socks.md",
"/en/config/outbounds/trojan.md",
"/en/config/outbounds/vless.md",
"/en/config/outbounds/vmess.md",
"/en/config/outbounds/wireguard.md",
],
},
{
text: "transport",
children: [
"/en/config/transports/raw.md",
"/en/config/transports/xhttp.md",
"/en/config/transports/mkcp.md",
"/en/config/transports/grpc.md",
"/en/config/transports/websocket.md",
"/en/config/transports/httpupgrade.md",
],
},
],
"/en/document/": [
{
text: "Quick Start",
children: [
"/en/document/README.md",
"/en/document/install.md",
"/en/document/config.md",
"/en/document/command.md",
"/en/document/document.md",
],
},
{
text: "Beginner Tutorial",
children: [
"/en/document/level-0/README.md",
"/en/document/level-0/ch01-preface.md",
"/en/document/level-0/ch02-preparation.md",
"/en/document/level-0/ch03-ssh.md",
"/en/document/level-0/ch04-security.md",
"/en/document/level-0/ch05-webpage.md",
"/en/document/level-0/ch06-certificates.md",
"/en/document/level-0/ch07-xray-server.md",
"/en/document/level-0/ch08-xray-clients.md",
"/en/document/level-0/ch09-appendix.md",
],
},
{
text: "Getting Started Tips",
children: [
"/en/document/level-1/README.md",
"/en/document/level-1/fallbacks-lv1.md",
"/en/document/level-1/routing-lv1-part1.md",
"/en/document/level-1/routing-lv1-part2.md",
"/en/document/level-1/work.md",
"/en/document/level-1/fallbacks-with-sni.md",
],
},
{
text: "Advanced Documentation",
children: [
"/en/document/level-2/README.md",
"/en/document/level-2/transparent_proxy/transparent_proxy.md",
"/en/document/level-2/tproxy.md",
"/en/document/level-2/tproxy_ipv4_and_ipv6.md",
"/en/document/level-2/nginx_or_haproxy_tls_tunnel.md",
"/en/document/level-2/iptables_gid.md",
"/en/document/level-2/redirect.md",
"/en/document/level-2/warp.md",
"/en/document/level-2/traffic_stats.md",
],
},
],
"/en/development/": [
{
text: "Developer Guide",
children: [
"/en/development/README.md",
"/en/development/intro/compile.md",
"/en/development/intro/design.md",
"/en/development/intro/guide.md",
],
},
{
text: "Protocol Details",
children: [
"/en/development/protocols/vless.md",
"/en/development/protocols/vmess.md",
"/en/development/protocols/muxcool.md",
"/en/development/protocols/mkcp.md",
],
},
],
};
-3
View File
@@ -1,3 +0,0 @@
export * from "./en.js";
export * from "./zh.js";
export * from "./ru.js";
-148
View File
@@ -1,148 +0,0 @@
import type { SidebarConfig } from "@vuepress/theme-default";
export const sidebarRu: SidebarConfig = {
"/ru/config/": [
{
text: "Описание функций",
children: [
"/ru/config/features/xtls.md",
"/ru/config/features/fallback.md",
"/ru/config/features/browser_dialer.md",
"/ru/config/features/env.md",
"/ru/config/features/multiple.md",
],
},
{
text: "Базовая конфигурация",
children: [
"/ru/config/README.md",
"/ru/config/log.md",
"/ru/config/api.md",
"/ru/config/dns.md",
"/ru/config/fakedns.md",
"/ru/config/inbound.md",
"/ru/config/outbound.md",
"/ru/config/policy.md",
"/ru/config/reverse.md",
"/ru/config/routing.md",
"/ru/config/stats.md",
"/ru/config/transport.md",
"/ru/config/metrics.md",
"/ru/config/observatory.md",
],
},
{
text: "Входящие подключения",
children: [
"/ru/config/inbounds/tunnel.md",
"/ru/config/inbounds/http.md",
"/ru/config/inbounds/shadowsocks.md",
"/ru/config/inbounds/socks.md",
"/ru/config/inbounds/trojan.md",
"/ru/config/inbounds/vless.md",
"/ru/config/inbounds/vmess.md",
"/ru/config/inbounds/wireguard.md",
],
},
{
text: "Исходящие подключения",
children: [
"/ru/config/outbounds/blackhole.md",
"/ru/config/outbounds/dns.md",
"/ru/config/outbounds/freedom.md",
"/ru/config/outbounds/http.md",
"/ru/config/outbounds/loopback.md",
"/ru/config/outbounds/shadowsocks.md",
"/ru/config/outbounds/socks.md",
"/ru/config/outbounds/trojan.md",
"/ru/config/outbounds/vless.md",
"/ru/config/outbounds/vmess.md",
"/ru/config/outbounds/wireguard.md",
],
},
{
text: "Транспортный уровень",
children: [
"/ru/config/transports/raw.md",
"/ru/config/transports/xhttp.md",
"/ru/config/transports/mkcp.md",
"/ru/config/transports/grpc.md",
"/ru/config/transports/websocket.md",
"/ru/config/transports/httpupgrade.md",
],
},
],
"/ru/document/": [
{
text: "Быстрый старт",
children: [
"/ru/document/README.md",
"/ru/document/install.md",
"/ru/document/config.md",
"/ru/document/command.md",
"/ru/document/document.md",
],
},
{
text: "Простыми словами",
children: [
"/ru/document/level-0/README.md",
"/ru/document/level-0/ch01-preface.md",
"/ru/document/level-0/ch02-preparation.md",
"/ru/document/level-0/ch03-ssh.md",
"/ru/document/level-0/ch04-security.md",
"/ru/document/level-0/ch05-webpage.md",
"/ru/document/level-0/ch06-certificates.md",
"/ru/document/level-0/ch07-xray-server.md",
"/ru/document/level-0/ch08-xray-clients.md",
"/ru/document/level-0/ch09-appendix.md",
],
},
{
text: "Базовые навыки",
children: [
"/ru/document/level-1/README.md",
"/ru/document/level-1/fallbacks-lv1.md",
"/ru/document/level-1/routing-lv1-part1.md",
"/ru/document/level-1/routing-lv1-part2.md",
"/ru/document/level-1/work.md",
"/ru/document/level-1/fallbacks-with-sni.md",
"/ru/document/level-1/routing-with-dns.md",
],
},
{
text: "Продвинутые навыки",
children: [
"/ru/document/level-2/README.md",
"/ru/document/level-2/transparent_proxy/transparent_proxy.md",
"/ru/document/level-2/tproxy.md",
"/ru/document/level-2/tproxy_ipv4_and_ipv6.md",
"/ru/document/level-2/nginx_or_haproxy_tls_tunnel.md",
"/ru/document/level-2/iptables_gid.md",
"/ru/document/level-2/redirect.md",
"/ru/document/level-2/warp.md",
"/ru/document/level-2/traffic_stats.md",
],
},
],
"/ru/development/": [
{
text: "Руководство разработчика",
children: [
"/ru/development/README.md",
"/ru/development/intro/compile.md",
"/ru/development/intro/design.md",
"/ru/development/intro/guide.md",
],
},
{
text: "Описание протоколов",
children: [
"/ru/development/protocols/vless.md",
"/ru/development/protocols/vmess.md",
"/ru/development/protocols/muxcool.md",
"/ru/development/protocols/mkcp.md",
],
},
],
};
-148
View File
@@ -1,148 +0,0 @@
import type { SidebarConfig } from "@vuepress/theme-default";
export const sidebarZh: SidebarConfig = {
"/config/": [
{
text: "特性详解",
children: [
"/config/features/xtls.md",
"/config/features/fallback.md",
"/config/features/browser_dialer.md",
"/config/features/env.md",
"/config/features/multiple.md",
],
},
{
text: "基础配置",
children: [
"/config/README.md",
"/config/log.md",
"/config/api.md",
"/config/dns.md",
"/config/fakedns.md",
"/config/inbound.md",
"/config/outbound.md",
"/config/policy.md",
"/config/reverse.md",
"/config/routing.md",
"/config/stats.md",
"/config/transport.md",
"/config/metrics.md",
"/config/observatory.md",
],
},
{
text: "入站协议",
children: [
"/config/inbounds/tunnel.md",
"/config/inbounds/http.md",
"/config/inbounds/shadowsocks.md",
"/config/inbounds/socks.md",
"/config/inbounds/trojan.md",
"/config/inbounds/vless.md",
"/config/inbounds/vmess.md",
"/config/inbounds/wireguard.md",
],
},
{
text: "出站协议",
children: [
"/config/outbounds/blackhole.md",
"/config/outbounds/dns.md",
"/config/outbounds/freedom.md",
"/config/outbounds/http.md",
"/config/outbounds/loopback.md",
"/config/outbounds/shadowsocks.md",
"/config/outbounds/socks.md",
"/config/outbounds/trojan.md",
"/config/outbounds/vless.md",
"/config/outbounds/vmess.md",
"/config/outbounds/wireguard.md",
],
},
{
text: "底层传输",
children: [
"/config/transports/raw.md",
"/config/transports/xhttp.md",
"/config/transports/mkcp.md",
"/config/transports/grpc.md",
"/config/transports/websocket.md",
"/config/transports/httpupgrade.md",
],
},
],
"/document/": [
{
text: "快速入门文档",
children: [
"/document/README.md",
"/document/install.md",
"/document/config.md",
"/document/command.md",
"/document/document.md",
],
},
{
text: "小小白白话文",
children: [
"/document/level-0/README.md",
"/document/level-0/ch01-preface.md",
"/document/level-0/ch02-preparation.md",
"/document/level-0/ch03-ssh.md",
"/document/level-0/ch04-security.md",
"/document/level-0/ch05-webpage.md",
"/document/level-0/ch06-certificates.md",
"/document/level-0/ch07-xray-server.md",
"/document/level-0/ch08-xray-clients.md",
"/document/level-0/ch09-appendix.md",
],
},
{
text: "入门技巧",
children: [
"/document/level-1/README.md",
"/document/level-1/fallbacks-lv1.md",
"/document/level-1/routing-lv1-part1.md",
"/document/level-1/routing-lv1-part2.md",
"/document/level-1/work.md",
"/document/level-1/fallbacks-with-sni.md",
"/document/level-1/routing-with-dns.md",
],
},
{
text: "进阶技巧",
children: [
"/document/level-2/README.md",
"/document/level-2/transparent_proxy/transparent_proxy.md",
"/document/level-2/tproxy.md",
"/document/level-2/tproxy_ipv4_and_ipv6.md",
"/document/level-2/nginx_or_haproxy_tls_tunnel.md",
"/document/level-2/iptables_gid.md",
"/document/level-2/redirect.md",
"/document/level-2/warp.md",
"/document/level-2/traffic_stats.md",
],
},
],
"/development/": [
{
text: "开发指南",
children: [
"/development/README.md",
"/development/intro/compile.md",
"/development/intro/design.md",
"/development/intro/guide.md",
],
},
{
text: "协议详解",
children: [
"/development/protocols/vless.md",
"/development/protocols/vmess.md",
"/development/protocols/muxcool.md",
"/development/protocols/mkcp.md",
],
},
],
};
@@ -1,9 +0,0 @@
// FIXME: Should correct handle dark selector
export const getDarkmodeStatus = (): boolean => {
const html = document.documentElement;
return (
html.classList.contains("dark") ||
html.getAttribute("data-theme") === "dark"
);
};
@@ -1,68 +0,0 @@
import type { PluginSimple } from "markdown-it";
import type Renderer from "markdown-it/lib/renderer.js";
const mermaidRenderer: Renderer.RenderRule = (tokens: any, index: any) =>
`<Mermaid id="mermaid-${index}" code="${encodeURI(
tokens[index].content,
)}"></Mermaid>`;
interface MermaidOptions {
content: string;
diagram?: string;
title?: string;
}
export const getMermaidContent = ({
diagram = "mermaid",
content,
title = "",
}: MermaidOptions): string => `\
${
title
? `\
---
title: ${title}
---
`
: ""
}\
${
diagram === "mermaid"
? ""
: `\
${diagram}
`
}\
${
diagram === "mermaid" || diagram === "sankey-beta"
? content
: content
.split("\n")
.map((line) => (line ? ` ${line}` : ""))
.join("\n")
}\
`;
const getMermaid = (options: MermaidOptions, index: number): string =>
`<Mermaid id="mermaid-${index}" code="${encodeURI(getMermaidContent(options))}"${options.title ? ` title="${encodeURI(options.title)}"` : ""}></Mermaid>`;
export const MermaidPlugin: PluginSimple = (md) => {
// Handle ```mermaid blocks
const fence = md.renderer.rules.fence;
md.renderer.rules.fence = (...args): string => {
const [tokens, index] = args;
const { content, info } = tokens[index];
const fenceInfo = info.trim();
if (fenceInfo === "mermaid") return getMermaid({ content }, index);
const [name, ...rest] = fenceInfo.split(" ");
return fence!(...args);
};
md.renderer.rules["mermaid"] = mermaidRenderer;
};
Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

-70
View File
@@ -1,70 +0,0 @@
:root {
--c-brand: #407ce8;
--c-brand-light: #2e73ea;
--c-text-accent: #2e73ea;
--c-brand-lighter: rgba(46, 115, 234, 0.75);
--c-bg-light: rgba(95, 101, 106, 0.1);
--c-badge-tip: #44c98d;
--c-warning-text-accent: var(--c-text-accent);
--c-danger-text-accent: var(--c-text-accent);
--x-nav-text-hover: #0a51bd;
}
html.dark {
--c-bg: #262a31;
--c-bg-light: #31353e;
--c-bg-lighter: #3a4049;
--c-brand: #407ce8;
--c-brand-light: #2e73ea;
--c-brand-lighter: rgba(46, 115, 234, 0.8);
--c-warning-bg: rgba(185, 174, 119, 0.3);
--c-warning-text: #c0bebe;
--c-warning-text-accent: var(--c-text-accent);
--c-danger-title: #b40505;
--c-danger-bg: rgba(72, 56, 57, 0.4);
--c-danger-text: #c0bebe;
--c-danger-text-accent: var(--c-text-accent);
--c-bg-light: rgba(255, 255, 255, 0.1);
--x-nav-text-hover: #7ca6f2;
.badge.tip > a {
color: #305bac;
& > span > svg.icon.outbound {
color: #7d57b0;
}
}
}
.badge.tip > a {
color: #3c71c0;
& > span > svg.icon.outbound {
color: #ad74e1;
}
}
blockquote {
color: var(--c-text);
background-color: var(--c-bg-lighter);
border-left: 4px solid #17a2b8;
}
* {
scroll-behavior: smooth;
transition: background-color 0.1s ease;
@media screen and (prefers-reduced-motion: reduce) {
scroll-behavior: auto;
}
}
.meta-item.edit-link > a.meta-item-label {
color: var(--c-text-accent);
}
.sidebar {
scrollbar-color: var(--c-brand-lighter) var(--c-border);
}
-98
View File
@@ -1,98 +0,0 @@
import { defaultTheme } from "@vuepress/theme-default";
// import { path, getDirname } from '@vuepress/utils'
import { path, getDirname } from "vuepress/utils";
import process from "node:process";
import {
navbarEn,
navbarZh,
navbarRu,
sidebarEn,
sidebarZh,
sidebarRu,
} from "./config/index.js";
let __dirname = getDirname(import.meta.url);
const isProduction = process.env.NODE_ENV === "production";
export default defaultTheme({
name: "vuepress-theme-xray",
smoothScroll: true,
repo: "xtls/xray-core",
docsDir: "docs",
docsRepo: "xtls/Xray-docs-next",
docsBranch: "main",
editLinks: true,
enableToggle: true,
locales: {
"/": {
navbar: navbarZh,
sidebar: sidebarZh,
repoLabel: "查看源码",
editLinkText: "帮助我们改善此页面!",
tip: "提示",
warning: "注意",
danger: "警告",
lastUpdatedText: "最近更改",
selectLanguageName: "简体中文",
selectLanguageText: "🌏 简体中文 / Change language",
selectLanguageAriaLabel: "简体中文 / Change language",
docsDir: "docs",
backToHome: "back to home",
openInNewWindow: "open in new tag",
toggleColorMode: "toggle color mode",
toggleSidebar: "toggle side bar",
},
"/en/": {
// TODO: translation
sidebar: sidebarEn,
navbar: navbarEn,
selectLanguageName: "English (WIP)",
selectLanguageText: "🌎 English / Change language",
selectLanguageAriaLabel: "English / Change language",
editLinkText: "Help us improve this page on GitHub!",
lastUpdatedText: "Last Updated",
contributorsText: "contributors",
// repoLabel: 'Source',
tip: "Tip",
warning: "Warning",
danger: "Danger",
// 404 page
notFound: [
"这里什么都没有",
"我们怎么到这来了?",
"这是一个 404 页面",
"看起来我们进入了错误的链接",
],
backToHome: "back to home",
openInNewWindow: "open in new tag",
toggleColorMode: "toggle color mode",
toggleSidebar: "toggle side bar",
},
"/ru/": {
navbar: navbarRu,
sidebar: sidebarRu,
repoLabel: "Посмотреть исходный код",
editLinkText: "Помогите нам улучшить эту страницу!",
tip: "Подсказка",
warning: "Внимание",
danger: "Предупреждение",
lastUpdatedText: "Последние изменения",
selectLanguageName: "Русский",
selectLanguageText: "🌍 Русский / Change language",
selectLanguageAriaLabel: "Русский / Change language",
docsDir: "docs",
backToHome: "На главную",
openInNewWindow: "Открыть в новой вкладке",
toggleColorMode: "Переключить цветовую схему",
toggleSidebar: "Переключить боковую панель",
},
// logo: '/logo.png',
// sidebar: 'auto',
themePlugins: {
git: isProduction,
},
},
});
-1
View File
@@ -1 +0,0 @@
# Xray-docs-next theme
-11
View File
@@ -1,11 +0,0 @@
// import { defineClientAppEnhance } from "@vuepress/client";
import { defineClientAppEnhance } from "vuepress/client";
import Tab from "./components/Tab.vue";
import Tabs from "./components/Tabs.vue";
import Mermaid from "./components/Mermaid.vue";
export default defineClientAppEnhance(({ app, router, siteData }) => {
app.component("Tab", Tab);
app.component("Tabs", Tabs);
app.component("Mermaid", Mermaid);
});
@@ -1,82 +0,0 @@
<template>
<div v-html="payload.innerHtml"></div>
</template>
<script lang="ts">
import { useMutationObserver } from "@vueuse/core";
import {
computed,
defineComponent,
h,
onMounted,
ref,
shallowRef,
watch,
reactive,
nextTick,
toRef,
} from "vue";
import { getDarkmodeStatus } from "../../plugins/mermaid/helpers/darkmode.js";
export default defineComponent({
name: "Mermaid",
props: {
id: { type: String, required: true },
code: { type: String, required: true },
},
setup(props) {
const html = reactive({ innerHtml: "" });
const chartID = toRef(props, "id");
const rawGraph = toRef(props, "code");
const isDarkmode = ref(false);
const renderMermaid = async (): Promise<void> => {
const mermaid = await import("mermaid");
mermaid.default.initialize({
theme: isDarkmode.value ? "dark" : "default",
startOnLoad: false,
});
mermaid.default
.render(chartID.value!, decodeURI(rawGraph.value!))
.then(({ svg, bindFunctions }) => {
html.innerHtml = svg;
});
};
onMounted(() => {
isDarkmode.value = getDarkmodeStatus();
nextTick(renderMermaid);
});
// watch darkmode change
if (typeof document !== "undefined") {
useMutationObserver(
document.documentElement,
() => {
isDarkmode.value = getDarkmodeStatus();
},
{
attributeFilter: ["class", "data-theme"],
attributes: true,
},
);
}
watch(isDarkmode, () => renderMermaid());
return {
tag: chartID,
payload: html,
};
},
});
</script>
<style scoped></style>
-41
View File
@@ -1,41 +0,0 @@
<template>
<div
class="tab-pane fade"
:id="tabID"
role="tabpanel"
:aria-labelledby="labelID"
>
<slot />
</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
props: {
title: {
type: String,
},
},
data() {
let tag = this.title;
return {
tabID: tag,
};
},
mounted() {
this.tabID = "tab-" + Math.random().toString(36).substring(2);
this.$parent.$data.children.push({ id: this.tabID, title: this.title });
},
computed: {
labelID(): String {
return this.tabID + "-label";
},
},
});
</script>
<style lang="scss" scoped>
@import "node_modules/bootstrap/scss/bootstrap";
</style>
-79
View File
@@ -1,79 +0,0 @@
<template>
<div class="container">
<nav>
<div :id="tag" class="nav nav-pills" role="tablist">
<button
v-for="tab of children"
:id="tab.id + '-label'"
:aria-controls="tab.id"
:data-bs-target="'#' + tab.id"
aria-selected="false"
class="nav-link"
data-bs-toggle="tab"
role="tab"
type="button"
>
{{ tab.title }}
</button>
</div>
</nav>
<div :id="contentTag" class="tab-content">
<slot />
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
props: {
title: {
type: String,
},
},
data() {
return {
children: [],
};
},
beforeMount() {
this.children = [];
},
mounted() {
this.$nextTick(async function () {
const bootstrap = await import("bootstrap");
let triggerEl = document.getElementById(this.children["0"].id + "-label");
new bootstrap.Tab(triggerEl).show();
});
},
computed: {
tag: function () {
return "tabs-" + this.title;
},
contentTag: function () {
return "tabs-" + this.title + "-content";
},
},
});
</script>
<style lang="scss" scoped>
@import "node_modules/bootstrap/scss/bootstrap";
button.nav-link {
color: var(--c-text-accent);
&:hover,
&:focus {
color: var(--x-nav-text-hover);
}
}
nav {
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--c-border);
}
div.tab-content {
border-bottom: 1px solid var(--c-border);
}
</style>
-15
View File
@@ -1,15 +0,0 @@
// import { Theme } from "@vuepress/core";
import { Theme } from "vuepress/core";
// import { path } from "@vuepress/utils";
import { path } from "vuepress/utils";
import { defaultTheme } from "vuepress";
export const docsPlugin: Theme = (options, app) => {
return defaultTheme({
name: "xray-docs-theme",
extends: "@vuepress/theme-default",
clientAppEnhanceFiles: path.resolve(__dirname, "clientAppEnhance.ts"),
});
};
export default docsPlugin;