Skip to content

Commit

Permalink
✨ 更新vitepress,优化字体引入方式,移除投毒cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
Redlnn committed Jul 27, 2024
1 parent 08541c6 commit 3a29c5e
Show file tree
Hide file tree
Showing 43 changed files with 2,885 additions and 3,645 deletions.
62 changes: 5 additions & 57 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,19 @@ jobs:
build_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Processing fonts
run: |
python3 -m pip install brotli fonttools
python3 scripts/minfont.py
- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '>=18'
node-version: '>=20'
cache: 'pnpm'

- name: Build docs
Expand All @@ -41,55 +32,12 @@ jobs:
name: page_dist
path: docs/.vitepress/dist

upload2cos:
needs: [build_docs]
if: ${{ false }}
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: page_dist
path: dist

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install coscmd
run: python3 -m pip install coscmd

- name: Upload dist
run: |
coscmd config -a ${{ secrets.SecretId }} -s ${{ secrets.SecretKey }} -b graiax-1257296418 -r ap-hongkong
coscmd upload -rs --delete -y dist/ /
upload2a60:
needs: [build_docs]
if: ${{ false }}
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: page_dist
path: dist

- name: Upload ftp
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./dist/

upload2netlify:
needs: [build_docs]
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: page_dist
path: dist
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/components/Curtain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<script setup lang="ts">
interface Props {
title: string
title?: string
}

withDefaults(defineProps<Props>(), {
Expand Down
39 changes: 20 additions & 19 deletions docs/.vitepress/config.ts → docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { defineConfig } from 'vitepress'

import { before, guide, appendix } from './sidebar'

import mdEnhance from './mdEnhance/index'
import { before, guide, appendix } from './sidebar'
function nav() {
return [
{ text: '开始之前', link: '/before/', activeMatch: '/before/' },
{ text: '实战演练', link: '/guide/', activeMatch: '/guide/' },
{ text: '附录', link: '/appendix/credit', activeMatch: '/appendix/' },
{ text: 'Graia 官方文档', link: 'https://graia.cn/' }
]
}

// https://vitepress.dev/reference/site-config
export default defineConfig({
lang: 'zh-CN',

Expand All @@ -15,10 +23,11 @@ export default defineConfig({

head: [
['link', { rel: 'shortcut icon', href: '/favicon.png' }],
['script', { src: 'https://cdn.bootcdn.net/ajax/libs/mermaid/10.3.0/mermaid.min.js' }]
['script', { src: 'https://cdn.jsdelivr.net/npm/mermaid@10.9.1/dist/mermaid.min.js' }]
],

themeConfig: {
// https://vitepress.dev/reference/default-theme-config
i18nRouting: true,
logo: '/logo.svg',
nav: nav(),
Expand Down Expand Up @@ -52,9 +61,16 @@ export default defineConfig({
returnToTopLabel: '回到顶部 ▲'
},

markdown: {
theme: 'one-dark-pro',
lineNumbers: true,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config: mdEnhance as any
},

transformHead({ assets }) {
// adjust the regex accordingly to match your font
const HarmonySansFile = assets.find(() => /HarmonyOS_Sans_SC\.woff2/)
const HarmonySansFile = assets.find(() => /.+\.woff2/)
if (HarmonySansFile) {
return [
[
Expand All @@ -70,19 +86,4 @@ export default defineConfig({
]
}
},

markdown: {
theme: 'one-dark-pro',
lineNumbers: true,
config: mdEnhance
}
})

function nav() {
return [
{ text: '开始之前', link: '/before/', activeMatch: '/before/' },
{ text: '实战演练', link: '/guide/', activeMatch: '/guide/' },
{ text: '附录', link: '/appendix/credit', activeMatch: '/appendix/' },
{ text: 'Graia 官方文档', link: 'https://graia.cn/' }
]
}
159 changes: 0 additions & 159 deletions docs/.vitepress/mdEnhance/components/CodeGroup.ts

This file was deleted.

64 changes: 0 additions & 64 deletions docs/.vitepress/mdEnhance/components/CodeGroupItem.vue

This file was deleted.

Loading

0 comments on commit 3a29c5e

Please sign in to comment.