Skip to content

Commit 34e9e62

Browse files
authored
Merge pull request #2 from ArcletProject/refactor
💥 use vitepress
2 parents 42cd6aa + 9852a4e commit 34e9e62

File tree

136 files changed

+8134
-26509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+8134
-26509
lines changed

.github/workflows/deploy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
2+
#
3+
name: Deploy VitePress site to Pages
4+
5+
on:
6+
# 在针对 `main` 分支的推送上运行。如果你
7+
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
8+
push:
9+
branches: [main]
10+
tags:
11+
- v*
12+
13+
# 允许你从 Actions 选项卡手动运行此工作流程
14+
workflow_dispatch:
15+
16+
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
17+
permissions:
18+
contents: read
19+
pages: write
20+
id-token: write
21+
22+
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
23+
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
24+
concurrency:
25+
group: pages
26+
cancel-in-progress: false
27+
28+
jobs:
29+
# 构建工作
30+
build:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
37+
# - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
38+
# with:
39+
# version: 9
40+
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
41+
- name: Setup Node
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: 20
45+
cache: npm # 或 pnpm / yarn
46+
- name: Setup Pages
47+
uses: actions/configure-pages@v4
48+
- name: Install dependencies
49+
run: npm ci # 或 pnpm install / yarn install / bun install
50+
- name: Build with VitePress
51+
run: npm run docs:build # 或 pnpm docs:build / yarn docs:build / bun run docs:build
52+
- name: Upload artifact
53+
uses: actions/upload-pages-artifact@v3
54+
with:
55+
path: .vitepress/dist
56+
57+
# 部署工作
58+
deploy:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
name: Deploy
62+
steps:
63+
- name: Deploy to GitHub Pages
64+
id: deployment
65+
uses: peaceiris/actions-gh-pages@v4
66+
with:
67+
github_token: ${{ secrets.GITHUB_TOKEN }}
68+
publish_dir: .vitepress/dist
69+
external_repository: ArcletProject/ArcletProject.github.io
70+
publish_branch: main # org.github.io 仓库的主分支
71+
force_orphan: 'true'

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
npm-debug.log*
1919
yarn-debug.log*
2020
yarn-error.log*
21+
22+
# Vitepress
23+
.vitepress/dist
24+
.vitepress/cache

.idea/Documents.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vitepress/components/QWindow.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
Author: I Love Study <1450069615@qq.com>
3+
Author: Redlnn <w731347477@gmail.com>
4+
-->
5+
<script setup lang="ts">
6+
defineProps<{
7+
title?: string
8+
}>()
9+
</script>
10+
11+
<template>
12+
<section class="qq">
13+
<q-header>{{ title }}</q-header>
14+
<q-main><slot></slot></q-main>
15+
</section>
16+
</template>
17+
18+
<style lang="scss" scoped>
19+
.qq {
20+
width: 100%;
21+
background-color: var(--qq-background-03);
22+
border-radius: 10px;
23+
transition: background-color 0.2s;
24+
}
25+
</style>

.vitepress/config/index.mts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { defineConfig } from 'vitepress'
2+
import nav from './nav'
3+
import sidebar from './sidebar'
4+
import fence from "../markdown/fence";
5+
6+
// https://vitepress.dev/reference/site-config
7+
export default defineConfig({
8+
title: "ArcletProject",
9+
description: "Document for ArcletProject",
10+
head: [
11+
['link', { rel: 'icon', href: '/logo.png' }],
12+
["meta", { "name": "theme-color", "content": "#2564c2" }]
13+
],
14+
srcDir: './',
15+
srcExclude: ["./old/**", "./README.md"],
16+
themeConfig: {
17+
// https://vitepress.dev/reference/default-theme-config
18+
logo: '/logo.svg',
19+
nav: nav,
20+
sidebar: sidebar,
21+
editLink: {
22+
pattern: 'https://github.com/ArcletProject/Documents/edit/refactor/:path',
23+
text: '在 GitHub 编辑此页'
24+
},
25+
socialLinks: [
26+
{ icon: 'github', link: 'https://github.com/ArcletProject' }
27+
],
28+
29+
footer: {
30+
message: 'MIT License',
31+
copyright: 'Copyright © 2025 ArcletProject'
32+
},
33+
lastUpdated: {
34+
text: '上次更新',
35+
},
36+
outline: {
37+
label: '目录',
38+
level: [2, 3]
39+
},
40+
docFooter: {
41+
prev: '上一页',
42+
next: '下一页'
43+
},
44+
darkModeSwitchLabel: '黑暗模式',
45+
lightModeSwitchTitle: '切换到浅色模式',
46+
darkModeSwitchTitle: '切换到黑暗模式',
47+
sidebarMenuLabel: '目录',
48+
returnToTopLabel: '回到顶部 ▲',
49+
externalLinkIcon: true
50+
},
51+
markdown: {
52+
theme: {
53+
light: 'min-light',
54+
dark: 'one-dark-pro'
55+
},
56+
image: {
57+
lazyLoading: true
58+
},
59+
lineNumbers: true,
60+
config: (md) => {
61+
md.use(fence);
62+
}
63+
}
64+
})

.vitepress/config/nav.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default [
2+
{ text: '入门', link: '/tutorial/intro.md', activeMatch: '/tutorial/intro.md' },
3+
{
4+
text: '深入',
5+
items: [
6+
{ text: '开发指南', link: '/appendices/WIP.md', activeMatch: '/appendices/WIP.md' },
7+
]
8+
},
9+
]

.vitepress/config/sidebar.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const tutorial = [
2+
{
3+
text: "",
4+
items: [
5+
{ text: "概览", link: "/tutorial/intro.md" },
6+
]
7+
},
8+
{
9+
text: "教程",
10+
items: [
11+
{
12+
text: "Alconna",
13+
collapsed: true,
14+
items: [
15+
{ text: "1.8", link: "/tutorial/alconna/v1.md" },
16+
{ text: "2.0", link: "/tutorial/alconna/v2.md" }
17+
]
18+
},
19+
{
20+
text: "NEPattern",
21+
collapsed: true,
22+
items: [
23+
{ text: "0.6", link: "/tutorial/nepattern/v0.md" },
24+
{ text: "1.0", link: "/tutorial/nepattern/v1.md" }
25+
]
26+
},
27+
{
28+
text: "Cithub",
29+
link: "/tutorial/cithun.md"
30+
},
31+
{
32+
text: "Letoderea",
33+
link: "/tutorial/letoderea.md"
34+
},
35+
{
36+
text: "Entari",
37+
link: "/tutorial/entari.md"
38+
},
39+
{
40+
text: "Tarina",
41+
link: "/tutorial/tarina.md"
42+
}
43+
]
44+
}
45+
]
46+
47+
export default {
48+
"/tutorial/": tutorial,
49+
}

.vitepress/markdown/fence.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { htmlEscape } from '@mdit-vue/shared'
2+
import MarkdownIt from 'markdown-it'
3+
4+
export default (md: MarkdownIt) => {
5+
const fence = md.renderer.rules.fence
6+
md.renderer.rules.fence = (...args) => {
7+
let [tokens, index] = args
8+
const token = tokens[index]
9+
let prev: any, title: string
10+
let [language, ...rest] = token.info.split(/\s+/g)
11+
language = language.split(':')[0] // remove any prefix like `ts:`
12+
for (const text of rest) {
13+
if (text.startsWith('title=')) {
14+
title = text.slice(6)
15+
}
16+
}
17+
const rawCode = fence(...args).replace(/<span class="lang">(.+?)<\/span>/, () => {
18+
return `<span class="lang">${title || language}</span>`
19+
})
20+
while ((prev = tokens[--index])?.type === 'fence');
21+
const isCodeGroupItem = prev?.type === 'container_tabs_open'
22+
if (!isCodeGroupItem) return rawCode
23+
let result = `<template #tab-${language}>${rawCode}</template>`
24+
if (title) {
25+
result = `<template #title-${language}>${htmlEscape(title)}</template>` + result
26+
}
27+
return result
28+
}
29+
}

.vitepress/styles/code-group.scss

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.vp-code-group .tabs {
2+
padding: 0;
3+
background-color: inherit;
4+
border-radius: inherit;
5+
box-shadow: inherit;
6+
7+
label {
8+
font-size: 12px;
9+
line-height: inherit;
10+
padding: 4px 18px;
11+
background-color: var(--vp-code-tab-bg);
12+
border-bottom: solid 1px var(--vp-code-tab-divider);
13+
/* border-left: solid 1px var(--vp-code-tab-divider); */
14+
15+
&:first-of-type {
16+
border-top-left-radius: 8px;
17+
/* border-left: inherit; */
18+
}
19+
20+
&:last-of-type {
21+
border-top-right-radius: 8px;
22+
}
23+
}
24+
}
25+
26+
@media (min-width: 640px) {
27+
.vp-code-group div[class*='language-'],
28+
.vp-block {
29+
border-top-right-radius: 8px !important;
30+
}
31+
}

0 commit comments

Comments
 (0)