Skip to content

Commit

Permalink
添加双向链接支持、增强可读性,并更新依赖项
Browse files Browse the repository at this point in the history
使用 VitePress 插件添加了双向链接支持、新的贡献者组件、Git 提交历史、增强阅读体验;将 VitePress 更新到 v1.1.4 并更新其他依赖
  • Loading branch information
Big-Cake-jpg committed May 2, 2024
1 parent 32d6fed commit f99f0ff
Show file tree
Hide file tree
Showing 13 changed files with 5,356 additions and 3,804 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ cache
.pnp.loader.mjs
yarn.lock
dev-dist
vite.config.ts.timestamp*

#CloudIDE
.lightly
Expand Down
51 changes: 50 additions & 1 deletion .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { fileURLToPath } from "node:url"
import { defineConfig } from "vitepress"
import type { DefaultTheme } from "vitepress/theme"
import { withPwa, type PwaOptions } from "@vite-pwa/vitepress"
import { cwd } from 'node:process'
import { BiDirectionalLinks } from '@nolebase/markdown-it-bi-directional-links'
import {
InlineLinkPreviewElementTransform
} from '@nolebase/vitepress-plugin-inline-link-preview/markdown-it'
import {
GitChangelog,
GitChangelogMarkdownSection,
} from '@nolebase/vitepress-plugin-git-changelog/vite'

const COMMIT_ID = process.env.CF_PAGES_COMMIT_SHA || "local"
const commitRef = COMMIT_ID?.slice(0, 8)
Expand All @@ -15,13 +24,43 @@ const viteConfig = {
"@": fileURLToPath(new URL(".", import.meta.url)),
},
},
optimizeDeps: {
include: [
// @rive-app/canvas is a CJS/UMD module, so it needs to be included here
// for Vite to properly bundle it.
'@nolebase/vitepress-plugin-enhanced-readabilities > @nolebase/ui > @rive-app/canvas',
],
exclude: [
'@nolebase/vitepress-plugin-enhanced-readabilities/client',
],
},
ssr: {
noExternal: [
// 如果还有别的依赖需要添加的话,并排填写和配置到这里即可
'@nolebase/vitepress-plugin-enhanced-readabilities',
],
},
plugins: [
GitChangelog({
// 填写在此处填写您的仓库链接
repoURL: () => 'https://github.com/GlobeMC/crashmc.com',
}),
GitChangelogMarkdownSection({
locales: {
gitChangelogMarkdownSectionTitles: {
changelog: '文件历史',
contributors: '贡献者',
},
},
}),
]
}

const pwaConfig: PwaOptions = {
devOptions: {
enabled: true,
},
outDir: ".vitepress/dist",
outDir: "../.vitepress/dist",
registerType: "prompt",
includeManifestIcons: false,
manifest: {
Expand Down Expand Up @@ -60,6 +99,7 @@ const pwaConfig: PwaOptions = {
workbox: {
globPatterns: ["**/*.{css,js,html,svg,webp,ico,txt,woff2}"],
globIgnores: ["shortcuts/*.svg"],
globDirectory: ".vitepress/dist",
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
Expand Down Expand Up @@ -272,6 +312,15 @@ export default withPwa(
dark: "material-theme-palenight",
},
lineNumbers: true,
config: (md) => {
// @ts-expect-error TS2769
md.use(BiDirectionalLinks({
dir: "docs",
baseDir: "/",
})),
// @ts-expect-error TS2769
md.use(InlineLinkPreviewElementTransform)
},
},

sitemap: {
Expand Down
72 changes: 0 additions & 72 deletions .vitepress/theme/Layout.vue

This file was deleted.

41 changes: 33 additions & 8 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import type { EnhanceAppContext } from "vitepress"
import { useData, useRoute } from "vitepress"
import Theme from "vitepress/theme"
import DefaultTheme from "vitepress/theme"
import { h } from "vue"

// Layouts
import Layout from "./Layout.vue"

// Components
import LauncherBadge from "./global-components/LauncherBadge.vue"
import Contributors from "./components/Contributors.vue"
Expand All @@ -18,21 +15,40 @@ import imageViewer from "vitepress-plugin-image-viewer"
import vImageViewer from "vitepress-plugin-image-viewer/lib/vImageViewer.vue"
import codeblocksFold from "vitepress-plugin-codeblocks-fold" // import method
import vitepressBackToTop from "vitepress-plugin-back-to-top"
import {
NolebaseEnhancedReadabilitiesMenu,
NolebaseEnhancedReadabilitiesScreenMenu,
} from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import type { Options } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import {
NolebaseInlineLinkPreviewPlugin,
} from '@nolebase/vitepress-plugin-inline-link-preview/client'
import { InjectionKey } from '@nolebase/vitepress-plugin-inline-link-preview/client'
import '@nolebase/vitepress-plugin-inline-link-preview/client/style.css'
import {
NolebaseGitChangelogPlugin
} from '@nolebase/vitepress-plugin-git-changelog/client'

import '@nolebase/vitepress-plugin-git-changelog/client/style.css'

// Styles
import "./style.css"
import "vitepress-plugin-back-to-top/dist/style.css"
import "vitepress-plugin-codeblocks-fold/style/index.scss"
import "@andatoshiki/vitepress-plugin-nprogress/lib/css/index.css"
import "viewerjs/dist/viewer.min.css"
import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'

export default {
extends: Theme,
Layout: () => {
return h(Layout, null, {
extends: DefaultTheme,
Layout() {
return h(DefaultTheme.Layout, null, {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
"doc-footer-before": () => h(Contributors),
"layout-bottom": () => h(ReloadPrompt),
// 为较宽的屏幕的导航栏添加阅读增强菜单
'nav-bar-content-after': () => h(NolebaseEnhancedReadabilitiesMenu),
// 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单
'nav-screen-content-after': () => h(NolebaseEnhancedReadabilitiesScreenMenu),
})
},
enhanceApp(ctx: EnhanceAppContext) {
Expand All @@ -43,6 +59,15 @@ export default {
ctx.app.component("LauncherBadge", LauncherBadge)
vitepressNprogress(ctx)
ctx.app.component("vImageViewer", vImageViewer)
ctx.app.use(NolebaseInlineLinkPreviewPlugin)
ctx.app.use(NolebaseGitChangelogPlugin, {
// https://nolebase-integrations.ayaka.io/pages/zh-CN/integrations/vitepress-plugin-git-changelog/configure-ui.html#%E9%85%8D%E7%BD%AE%E9%80%89%E9%A1%B9
})
ctx.app.provide(InjectionKey, {
// inline-link-preview config...
popupWidth: 400,
popupHeight: 300,
})
// Why it doesn't work?
// const layouts = import.meta.glob("./layouts/*.vue")
// for (const path in layouts) {
Expand Down
4 changes: 4 additions & 0 deletions .vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@
--vp-badge-pcl-text: #ffffff;
--vp-badge-pcl-bg: #0069df;
}

.VPSocialLinks.VPNavBarSocialLinks.social-links {
margin-right: 0;
}
2 changes: 1 addition & 1 deletion docs/client/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Minecraft 客户端,是 Minecraft 游戏本身一大组成部分。通俗来说,玩家游玩的 Minecraft 游戏本身就是客户端。

客户端需要使用 `启动器` 启动。有关启动器,可以参考[基础知识](/basis.html)
客户端需要使用 `启动器` 启动。有关启动器,可以参考[[basis|基础知识]]

:::tip
如果您对 Minecraft 有较详细的理解,那么您不必完整阅读。
Expand Down
2 changes: 1 addition & 1 deletion docs/client/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ OpenJ9 is incompatible
:::

:::details 其他 Java 获取方法
从官网下载并手动安装 Java:[Java 8](https://cdn.crashmc.com/https://github.com/bell-sw/Liberica/releases/download/8u312%2B7/bellsoft-jre8u312+7-windows-amd64-full.msi | [JDK 17+](https://cdn.crashmc.com/https://github.com/bell-sw/Liberica/releases/download/17.0.1%2B12/bellsoft-jdk17.0.1+12-windows-amd64.msi)
从官网下载并手动安装 Java:[Java 8](https://cdn.crashmc.com/https://github.com/bell-sw/Liberica/releases/download/8u312%2B7/bellsoft-jre8u312+7-windows-amd64-full.msi) | [JDK 17+](https://cdn.crashmc.com/https://github.com/bell-sw/Liberica/releases/download/17.0.1%2B12/bellsoft-jdk17.0.1+12-windows-amd64.msi)

获取 (Java 9+) 且已存档的 JDK 包:<https://bell-sw.com/pages/downloads/#downloads>
:::
Expand Down
13 changes: 5 additions & 8 deletions docs/contribute/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ git clone https://github.com/{yourname}/crashmc.com.git

在涉及任何站外链接时,请优先添加官方链接,尽量避免不必要的第三方链接。

:::tip 提示
为了方便各位快速建立文档内页面的链接,我们已经为文档添加了双向链接支持。语法可以参考 [语法 | Nólëbase 集成](https://nolebase-integrations.ayaka.io/pages/zh-CN/integrations/markdown-it-bi-directional-links/syntax.html)
:::

如果某一个解决方案为特定启动器独占功能,我们提供了全局组件来标注它。示例如下:

```markdown
Expand All @@ -47,17 +51,10 @@ git clone https://github.com/{yourname}/crashmc.com.git
- <LauncherBadge type="bakaxl" text="仅 BakaXL" />
- <LauncherBadge type="pcl" text="仅 PCL2" />

如果您参与编辑了一篇文档的绝大部分,可以填写 Markdown Frontmatter contributor 字段,以将您的 GitHub 用户名添加到贡献者列表,格式如下。

```md
---
contributors: [username1, username2]
---
```
文档会自动记录每个页面的 Git 提交历史记录以及为此文件做过贡献的人员,并将这些信息显示在页面上。

:::warning 警告

- 请一定要使用 GitHub 用户名署名,否则我们无法获取您的头像。
- 上述代码中所使用的均为英文半角逗号!

:::
Expand Down
4 changes: 4 additions & 0 deletions docs/contribute/contributors.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
gitChangelog: false
---

<script setup>
import { VPTeamMembers } from 'vitepress/theme'
import members from "../../.vitepress/data/members.json"
Expand Down
34 changes: 19 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@
"devDependencies": {
"@andatoshiki/vitepress-plugin-nprogress": "^0.0.1",
"@giscus/vue": "^2.4.0",
"@nolebase/markdown-it-bi-directional-links": "2.0.0-rc10",
"@nolebase/vitepress-plugin-enhanced-readabilities": "2.0.0-rc10",
"@nolebase/vitepress-plugin-git-changelog": "2.0.0-rc10",
"@nolebase/vitepress-plugin-inline-link-preview": "2.0.0-rc10",
"@types/pako": "^2.0.3",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@vite-pwa/vitepress": "^0.4.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier-vue": "^4.2.0",
"eslint-plugin-vue": "^9.21.1",
"eslint-plugin-vue": "^9.25.0",
"husky": "^8.0.3",
"prettier": "^3.2.4",
"sass": "^1.70.0",
"prettier": "^3.2.5",
"sass": "^1.76.0",
"tslib": "^2.6.2",
"vite": "^5.2.8",
"vite-plugin-pwa": "^0.19.4",
"vitepress": "1.0.0-rc.41",
"vue": "^3.4.15",
"vite": "^5.2.10",
"vite-plugin-pwa": "^0.19.8",
"vitepress": "1.1.4",
"vue": "^3.4.26",
"vue-eslint-parser": "^9.4.2",
"vue-tsc": "^1.8.27",
"workbox-window": "^7.0.0",
"workbox-window": "^7.1.0",
"zhlint": "^0.7.4"
},
"keywords": [
Expand All @@ -49,17 +53,17 @@
"@gera2ld/tarjs": "^0.2.2",
"@types/js-cookie": "^3.0.6",
"@types/umami": "^0.1.5",
"@typescript-eslint/parser": "^6.20.0",
"axios": "^1.6.7",
"@typescript-eslint/parser": "^6.21.0",
"axios": "^1.6.8",
"directory-tree": "^3.5.1",
"js-cookie": "^3.0.5",
"jszip": "^3.10.1",
"pako": "^2.1.0",
"typescript": "^5.3.3",
"typescript": "^5.4.5",
"viewerjs": "^1.11.6",
"vitepress-plugin-back-to-top": "^1.0.1",
"vitepress-plugin-codeblocks-fold": "^1.2.28",
"vitepress-plugin-comment-with-giscus": "^1.1.12",
"vitepress-plugin-image-viewer": "^1.1.3"
"vitepress-plugin-comment-with-giscus": "^1.1.15",
"vitepress-plugin-image-viewer": "^1.1.4"
}
}
Loading

0 comments on commit f99f0ff

Please sign in to comment.