Skip to content

💥 use vitepress #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
#
name: Deploy VitePress site to Pages

on:
# 在针对 `main` 分支的推送上运行。如果你
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
push:
branches: [main]
tags:
- v*

# 允许你从 Actions 选项卡手动运行此工作流程
workflow_dispatch:

# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
group: pages
cancel-in-progress: false

jobs:
# 构建工作
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
# - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
# with:
# version: 9
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm # 或 pnpm / yarn
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: npm ci # 或 pnpm install / yarn install / bun install
- name: Build with VitePress
run: npm run docs:build # 或 pnpm docs:build / yarn docs:build / bun run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: .vitepress/dist

# 部署工作
deploy:
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .vitepress/dist
external_repository: ArcletProject/ArcletProject.github.io
publish_branch: main # org.github.io 仓库的主分支
force_orphan: 'true'
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Vitepress
.vitepress/dist
.vitepress/cache
1 change: 1 addition & 0 deletions .idea/Documents.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .vitepress/components/QWindow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Author: I Love Study <[email protected]>
Author: Redlnn <[email protected]>
-->
<script setup lang="ts">
defineProps<{
title?: string
}>()
</script>

<template>
<section class="qq">
<q-header>{{ title }}</q-header>
<q-main><slot></slot></q-main>
</section>
</template>

<style lang="scss" scoped>
.qq {
width: 100%;
background-color: var(--qq-background-03);
border-radius: 10px;
transition: background-color 0.2s;
}
</style>
64 changes: 64 additions & 0 deletions .vitepress/config/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { defineConfig } from 'vitepress'
import nav from './nav'
import sidebar from './sidebar'
import fence from "../markdown/fence";

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "ArcletProject",
description: "Document for ArcletProject",
head: [
['link', { rel: 'icon', href: '/logo.png' }],
["meta", { "name": "theme-color", "content": "#2564c2" }]
],
srcDir: './',
srcExclude: ["./old/**", "./README.md"],
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: '/logo.svg',
nav: nav,
sidebar: sidebar,
editLink: {
pattern: 'https://github.com/ArcletProject/Documents/edit/refactor/:path',
text: '在 GitHub 编辑此页'
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/ArcletProject' }
],

footer: {
message: 'MIT License',
copyright: 'Copyright © 2025 ArcletProject'
},
lastUpdated: {
text: '上次更新',
},
outline: {
label: '目录',
level: [2, 3]
},
docFooter: {
prev: '上一页',
next: '下一页'
},
darkModeSwitchLabel: '黑暗模式',
lightModeSwitchTitle: '切换到浅色模式',
darkModeSwitchTitle: '切换到黑暗模式',
sidebarMenuLabel: '目录',
returnToTopLabel: '回到顶部 ▲',
externalLinkIcon: true
},
markdown: {
theme: {
light: 'min-light',
dark: 'one-dark-pro'
},
image: {
lazyLoading: true
},
lineNumbers: true,
config: (md) => {
md.use(fence);
}
}
})
9 changes: 9 additions & 0 deletions .vitepress/config/nav.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default [
{ text: '入门', link: '/tutorial/intro.md', activeMatch: '/tutorial/intro.md' },
{
text: '深入',
items: [
{ text: '开发指南', link: '/appendices/WIP.md', activeMatch: '/appendices/WIP.md' },
]
},
]
49 changes: 49 additions & 0 deletions .vitepress/config/sidebar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const tutorial = [
{
text: "",
items: [
{ text: "概览", link: "/tutorial/intro.md" },
]
},
{
text: "教程",
items: [
{
text: "Alconna",
collapsed: true,
items: [
{ text: "1.8", link: "/tutorial/alconna/v1.md" },
{ text: "2.0", link: "/tutorial/alconna/v2.md" }
]
},
{
text: "NEPattern",
collapsed: true,
items: [
{ text: "0.6", link: "/tutorial/nepattern/v0.md" },
{ text: "1.0", link: "/tutorial/nepattern/v1.md" }
]
},
{
text: "Cithub",
link: "/tutorial/cithun.md"
},
{
text: "Letoderea",
link: "/tutorial/letoderea.md"
},
{
text: "Entari",
link: "/tutorial/entari.md"
},
{
text: "Tarina",
link: "/tutorial/tarina.md"
}
]
}
]

export default {
"/tutorial/": tutorial,
}
29 changes: 29 additions & 0 deletions .vitepress/markdown/fence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { htmlEscape } from '@mdit-vue/shared'
import MarkdownIt from 'markdown-it'

export default (md: MarkdownIt) => {
const fence = md.renderer.rules.fence
md.renderer.rules.fence = (...args) => {
let [tokens, index] = args
const token = tokens[index]
let prev: any, title: string
let [language, ...rest] = token.info.split(/\s+/g)
language = language.split(':')[0] // remove any prefix like `ts:`
for (const text of rest) {
if (text.startsWith('title=')) {
title = text.slice(6)
}
}
const rawCode = fence(...args).replace(/<span class="lang">(.+?)<\/span>/, () => {
return `<span class="lang">${title || language}</span>`
})
while ((prev = tokens[--index])?.type === 'fence');
const isCodeGroupItem = prev?.type === 'container_tabs_open'
if (!isCodeGroupItem) return rawCode
let result = `<template #tab-${language}>${rawCode}</template>`
if (title) {
result = `<template #title-${language}>${htmlEscape(title)}</template>` + result
}
return result
}
}
31 changes: 31 additions & 0 deletions .vitepress/styles/code-group.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.vp-code-group .tabs {
padding: 0;
background-color: inherit;
border-radius: inherit;
box-shadow: inherit;

label {
font-size: 12px;
line-height: inherit;
padding: 4px 18px;
background-color: var(--vp-code-tab-bg);
border-bottom: solid 1px var(--vp-code-tab-divider);
/* border-left: solid 1px var(--vp-code-tab-divider); */

&:first-of-type {
border-top-left-radius: 8px;
/* border-left: inherit; */
}

&:last-of-type {
border-top-right-radius: 8px;
}
}
}

@media (min-width: 640px) {
.vp-code-group div[class*='language-'],
.vp-block {
border-top-right-radius: 8px !important;
}
}
Loading