mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 11:53:10 +08:00
fix: unify anchor IDs between VitePress and GitHub with custom slugify
Add GitHub-compatible slugify (github-slugger algorithm) to VitePress config so heading anchor IDs are consistent across both platforms. Update all inline anchor links in 22 doc files accordingly.
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
import { defineConfig } from 'vitepress'
|
||||
|
||||
// GitHub-compatible slugify (matches github-slugger algorithm)
|
||||
// Makes heading anchor IDs consistent between VitePress and GitHub rendering
|
||||
function slugify(str: string): string {
|
||||
return str
|
||||
.replace(/<[^>]*>/g, '')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/&/g, '&')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^\p{L}\p{M}\p{N}\p{Pc}\- ]/gu, '')
|
||||
.replace(/ /g, '-')
|
||||
}
|
||||
|
||||
const zhSidebar = [
|
||||
{
|
||||
text: '快速开始',
|
||||
@@ -136,6 +150,12 @@ export default defineConfig({
|
||||
lastUpdated: true,
|
||||
base: '/',
|
||||
|
||||
markdown: {
|
||||
anchor: {
|
||||
slugify,
|
||||
},
|
||||
},
|
||||
|
||||
head: [
|
||||
['script', { async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-D42DM82263' }],
|
||||
['script', {}, `window.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', 'G-D42DM82263');`],
|
||||
|
||||
Reference in New Issue
Block a user