From d993af3421e2d8ab444e98b5b82f58f908fe55e3 Mon Sep 17 00:00:00 2001 From: "Mr.Hope" Date: Fri, 28 Apr 2023 17:56:30 +0800 Subject: [PATCH] feat: add `@` alias for include --- docs/.vuepress/theme.ts | 16 +++++++++++++++- .../distributed-configuration-center.md | 2 +- .../distributed-transaction.md | 2 +- .../fallback&circuit-breaker.md | 2 +- docs/high-performance/sql-optimization.md | 2 +- docs/home.md | 2 +- .../interview-experience.md | 2 +- .../self-test-of-common-interview-questions.md | 2 +- docs/javaguide/faq.md | 2 +- docs/readme.md | 4 ++-- docs/{ => snippets}/banner.snippet.md | 0 docs/{ => snippets}/gzh.snippet.md | 0 docs/{ => snippets}/planet.snippet.md | 0 docs/system-design/system-design-questions.md | 2 +- package.json | 1 + pnpm-lock.yaml | 3 +++ 16 files changed, 30 insertions(+), 12 deletions(-) rename docs/{ => snippets}/banner.snippet.md (100%) rename docs/{ => snippets}/gzh.snippet.md (100%) rename docs/{ => snippets}/planet.snippet.md (100%) diff --git a/docs/.vuepress/theme.ts b/docs/.vuepress/theme.ts index 821935b3..a723eac5 100644 --- a/docs/.vuepress/theme.ts +++ b/docs/.vuepress/theme.ts @@ -1,8 +1,11 @@ +import { getDirname, path } from "@vuepress/utils"; import { hopeTheme } from "vuepress-theme-hope"; import navbar from "./navbar.js"; import sidebar from "./sidebar/index.js"; +const __dirname = getDirname(import.meta.url); + export default hopeTheme({ logo: "/logo.png", hostname: "https://javaguide.cn/", @@ -51,7 +54,18 @@ export default hopeTheme({ codetabs: true, container: true, figure: true, - include: true, + include: { + resolvePath: (file, cwd) => { + if (file.startsWith("@")) + return path.resolve( + __dirname, + "../snippets", + file.replace("@", "./") + ); + + return path.resolve(cwd, file); + }, + }, tasklist: true, }, feed: { diff --git a/docs/distributed-system/distributed-configuration-center.md b/docs/distributed-system/distributed-configuration-center.md index 718728da..12e2578f 100644 --- a/docs/distributed-system/distributed-configuration-center.md +++ b/docs/distributed-system/distributed-configuration-center.md @@ -12,4 +12,4 @@ icon: "configuration" ![](https://oss.javaguide.cn/xingqiu/image-20220304102536445.png) - + diff --git a/docs/distributed-system/distributed-transaction.md b/docs/distributed-system/distributed-transaction.md index 5df1584c..1a22e275 100644 --- a/docs/distributed-system/distributed-transaction.md +++ b/docs/distributed-system/distributed-transaction.md @@ -12,4 +12,4 @@ icon: "transanction" ![](https://oss.javaguide.cn/xingqiu/image-20220304102536445.png) - + diff --git a/docs/high-availability/fallback&circuit-breaker.md b/docs/high-availability/fallback&circuit-breaker.md index 0e7d5cf5..bea336d1 100644 --- a/docs/high-availability/fallback&circuit-breaker.md +++ b/docs/high-availability/fallback&circuit-breaker.md @@ -9,4 +9,4 @@ category: 高可用 ![](https://oss.javaguide.cn/xingqiu/image-20220304102536445.png) - + diff --git a/docs/high-performance/sql-optimization.md b/docs/high-performance/sql-optimization.md index 7a0d332d..ad39c4d2 100644 --- a/docs/high-performance/sql-optimization.md +++ b/docs/high-performance/sql-optimization.md @@ -19,4 +19,4 @@ head: ![](https://oss.javaguide.cn/xingqiu/image-20220304102536445.png) - + diff --git a/docs/home.md b/docs/home.md index bc9d38d7..1d10c683 100644 --- a/docs/home.md +++ b/docs/home.md @@ -20,7 +20,7 @@ title: JavaGuide(Java学习&&面试指南) [GitHub](https://github.com/Snailclimb/JavaGuide) | [Gitee](https://gitee.com/SnailClimb/JavaGuide) - + ## 项目相关 diff --git a/docs/interview-preparation/interview-experience.md b/docs/interview-preparation/interview-experience.md index c70ec7c1..1954a69b 100644 --- a/docs/interview-preparation/interview-experience.md +++ b/docs/interview-preparation/interview-experience.md @@ -19,4 +19,4 @@ category: 知识星球 ![](https://oss.javaguide.cn/xingqiu/image-20220628101805897.png) - + diff --git a/docs/interview-preparation/self-test-of-common-interview-questions.md b/docs/interview-preparation/self-test-of-common-interview-questions.md index 45b4e54a..d658ccf4 100644 --- a/docs/interview-preparation/self-test-of-common-interview-questions.md +++ b/docs/interview-preparation/self-test-of-common-interview-questions.md @@ -15,4 +15,4 @@ category: 知识星球 ![](https://oss.javaguide.cn/xingqiu/image-20220628102848236.png) - + diff --git a/docs/javaguide/faq.md b/docs/javaguide/faq.md index 192a12fc..41cdaf12 100644 --- a/docs/javaguide/faq.md +++ b/docs/javaguide/faq.md @@ -9,7 +9,7 @@ category: 走近项目 《JavaGuide 面试突击版》在我的公众号后台回复“**PDF**”即可获取,免费的。除了 《JavaGuide 面试突击版》之外,还会免费送你多本优质面试 PDF 手册。 - + ## 如何看待 JavaGuide 的 star 数量很多? diff --git a/docs/readme.md b/docs/readme.md index d00ade00..6e986d5c 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -16,7 +16,7 @@ footer: |- 鄂ICP备2020015769号-1 | 主题: VuePress Theme Hope --- - + ## 关于网站 @@ -44,4 +44,4 @@ footer: |- 最新更新会第一时间同步在公众号,推荐关注!另外,公众号上有很多干货不会同步在线阅读网站。 - + diff --git a/docs/banner.snippet.md b/docs/snippets/banner.snippet.md similarity index 100% rename from docs/banner.snippet.md rename to docs/snippets/banner.snippet.md diff --git a/docs/gzh.snippet.md b/docs/snippets/gzh.snippet.md similarity index 100% rename from docs/gzh.snippet.md rename to docs/snippets/gzh.snippet.md diff --git a/docs/planet.snippet.md b/docs/snippets/planet.snippet.md similarity index 100% rename from docs/planet.snippet.md rename to docs/snippets/planet.snippet.md diff --git a/docs/system-design/system-design-questions.md b/docs/system-design/system-design-questions.md index e5a9bbbc..6c321da7 100644 --- a/docs/system-design/system-design-questions.md +++ b/docs/system-design/system-design-questions.md @@ -12,4 +12,4 @@ icon: "design" ![](https://oss.javaguide.cn/xingqiu/image-20220304102536445.png) - + diff --git a/package.json b/package.json index 98f8c1a3..bf38de4f 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ }, "dependencies": { "@vuepress/client": "2.0.0-beta.61", + "@vuepress/utils": "2.0.0-beta.61", "husky": "8.0.3", "markdownlint-cli": "0.33.0", "nano-staged": "0.8.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6358a33e..ea7af189 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ dependencies: '@vuepress/client': specifier: 2.0.0-beta.61 version: 2.0.0-beta.61 + '@vuepress/utils': + specifier: 2.0.0-beta.61 + version: 2.0.0-beta.61 husky: specifier: 8.0.3 version: 8.0.3