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

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

View File

@@ -3,6 +3,7 @@ import path from 'path'
import { DefaultTheme } from 'vitepress'
export const genSidebar = (
lang: string,
dirPath: string,
options: {
title: string
@@ -10,7 +11,7 @@ export const genSidebar = (
ignore?: string[]
}
): DefaultTheme.SidebarItem => {
const sidebarPath = path.resolve(process.cwd(), dirPath)
const sidebarPath = path.resolve(process.cwd(), lang, dirPath)
const ignore = options.ignore || ['index.md']
const files = fs
@@ -22,9 +23,17 @@ export const genSidebar = (
const match = content.match(/^#\s+(.*)/)
const title = match ? match[1] : file.replace('.md', '')
let prefix = '/';
if (lang != 'en') {
prefix += lang;
prefix += '/';
}
return {
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:
- theme: brand
text: What is clice?
link: /en/guide/what-is-clice
link: /guide/what-is-clice
- theme: alt
text: Quick Start
link: /en/guide/quick-start
link: /guide/quick-start
- theme: alt
text: Contribution
link: /en/dev/contribution
link: /dev/contribution
image:
src: /image.png
alt: clice