Fix docs and improve ci (#182)

This commit is contained in:
ykiko
2025-08-17 11:47:44 +08:00
committed by GitHub
parent 1a258659fe
commit 41d5ac1173
6 changed files with 59 additions and 35 deletions

View File

@@ -1,9 +1,21 @@
name: format name: format
on: on:
pull_request:
push: push:
branches: [main] branches: [main]
paths:
- .clang-format
- "include/**"
- "src/**"
- "tests/**"
pull_request:
branches: [main]
paths:
- .clang-format
- "include/**"
- "src/**"
- "tests/**"
jobs: jobs:
check: check:

View File

@@ -3,18 +3,21 @@ name: cmake
on: on:
push: push:
branches: [main] branches: [main]
paths:
- ".github/workflows/cmake.yml"
- "include/**"
- "src/**"
- "tests/**"
- "CMakeLists.txt"
pull_request: pull_request:
branches: [main] branches: [main]
paths-ignore: paths:
- "docs" - ".github/workflows/cmake.yml"
- "scripts" - "include/**"
- ".clang-format" - "src/**"
- ".clangd" - "tests/**"
- ".gitignore" - "CMakeLists.txt"
- "LICENSE"
- "README.md"
- ".github/workflows/xmake.yml"
- "xmake.lua"
jobs: jobs:
build: build:

View File

@@ -3,20 +3,21 @@ name: xmake
on: on:
push: push:
branches: [main] branches: [main]
paths:
- ".github/workflows/xmake.yml"
- "include/**"
- "src/**"
- "tests/**"
- "xmake.lua"
pull_request: pull_request:
branches: [main] branches: [main]
paths-ignore: paths:
- "docs" - ".github/workflows/xmake.yml"
- "scripts" - "include/**"
- ".clang-format" - "src/**"
- ".clangd" - "tests/**"
- ".gitignore" - "xmake.lua"
- "LICENSE"
- "README.md"
- ".github/workflows/cmake.yml"
- "CMakeLists.txt"
- "CMakePresets.json"
- "cmake"
jobs: jobs:
linux: linux:

View File

@@ -18,17 +18,16 @@ export default defineConfig({
nav: [ nav: [
{ text: 'Home', link: '/' }, { text: 'Home', link: '/' },
], ],
sidebar: { sidebar: {
"/zh/": [ "/zh/": [
genSidebar('zh/design', { title: 'Design' }), genSidebar('zh', 'design', { title: 'Design' }),
genSidebar('zh/dev', { title: 'Development' }), genSidebar('zh', 'dev', { title: 'Development' }),
genSidebar('zh/guide', { title: 'Guide' }), genSidebar('zh', 'guide', { title: 'Guide' }),
], ],
"/": [ "/": [
genSidebar('en/design', { title: 'Design' }), genSidebar('en', 'design', { title: 'Design' }),
genSidebar('en/dev', { title: 'Development' }), genSidebar('en', 'dev', { title: 'Development' }),
genSidebar('en/guide', { title: 'Guide' }), genSidebar('en', 'guide', { title: 'Guide' }),
], ],
}, },
socialLinks: [ socialLinks: [

View File

@@ -3,6 +3,7 @@ import path from 'path'
import { DefaultTheme } from 'vitepress' import { DefaultTheme } from 'vitepress'
export const genSidebar = ( export const genSidebar = (
lang: string,
dirPath: string, dirPath: string,
options: { options: {
title: string title: string
@@ -10,7 +11,7 @@ export const genSidebar = (
ignore?: string[] ignore?: string[]
} }
): DefaultTheme.SidebarItem => { ): DefaultTheme.SidebarItem => {
const sidebarPath = path.resolve(process.cwd(), dirPath) const sidebarPath = path.resolve(process.cwd(), lang, dirPath)
const ignore = options.ignore || ['index.md'] const ignore = options.ignore || ['index.md']
const files = fs const files = fs
@@ -22,9 +23,17 @@ export const genSidebar = (
const match = content.match(/^#\s+(.*)/) const match = content.match(/^#\s+(.*)/)
const title = match ? match[1] : file.replace('.md', '') const title = match ? match[1] : file.replace('.md', '')
let prefix = '/';
if (lang != 'en') {
prefix += lang;
prefix += '/';
}
return { return {
text: title, text: title,
link: `/${dirPath}/${file.replace('.md', '')}` /// Make sure link for en is actually root, beacuse Github Pages
/// doesn't support redirect url.
link: `${prefix}${dirPath}/${file.replace('.md', '')}`
} }
}) })

View File

@@ -8,13 +8,13 @@ hero:
actions: actions:
- theme: brand - theme: brand
text: What is clice? text: What is clice?
link: /en/guide/what-is-clice link: /guide/what-is-clice
- theme: alt - theme: alt
text: Quick Start text: Quick Start
link: /en/guide/quick-start link: /guide/quick-start
- theme: alt - theme: alt
text: Contribution text: Contribution
link: /en/dev/contribution link: /dev/contribution
image: image:
src: /image.png src: /image.png
alt: clice alt: clice