11import { defineConfig } from 'vitepress'
2- import { withMermaid } from 'vitepress-plugin-mermaid'
3- import llmstxt from 'vitepress-plugin-llms'
42
53const rawBase = process . env . VITEPRESS_BASE
64const base = rawBase
@@ -10,93 +8,23 @@ const base = rawBase
108 : '/'
119
1210const siteTitle = 'C++ 高性能指南'
13- const siteDescription = '可运行的 C++ 性能工程文档,覆盖入门、指南、深度专题、算法、练习与参考。'
14- const siteUrl = 'https://lessup.github.io'
15- const canonicalBase = '/cpp-high-performance-guide/'
11+ const siteDescription = '可验证的现代 C++20 性能工程:内存布局、SIMD、无锁并发、构建系统,全部附带可运行代码与基准测试。'
1612const currentYear = new Date ( ) . getFullYear ( )
1713
18- function assetPath ( path : string ) : string {
19- const normalizedPath = path . replace ( / ^ \/ + / , '' )
20- return `${ base } ${ normalizedPath } `
21- }
22-
23- function canonicalAssetUrl ( path : string ) : string {
24- const normalizedPath = path . replace ( / ^ \/ + / , '' )
25- return new URL ( `${ canonicalBase . replace ( / ^ \/ + / , '' ) } ${ normalizedPath } ` , `${ siteUrl } /` ) . toString ( )
26- }
27-
28- const zhGettingStartedItems = [
29- { text : '先决条件' , link : '/zh/getting-started/prerequisites' } ,
30- { text : '安装指南' , link : '/zh/getting-started/installation' } ,
31- { text : '快速开始' , link : '/zh/getting-started/quickstart' } ,
32- ]
33-
34- const zhGuidesItems = [
35- { text : '学习路径' , link : '/zh/guides/learning-path' } ,
36- { text : '性能分析指南' , link : '/zh/guides/profiling-guide' } ,
37- { text : '验证与 Sanitizer' , link : '/zh/guides/validation' } ,
38- { text : '优化决策树' , link : '/zh/guides/optimization-decision-tree' } ,
39- { text : '最佳实践' , link : '/zh/guides/best-practices' } ,
40- ]
41-
42- const zhDeepDivesItems = [
43- { text : '内存布局' , link : '/zh/deep-dives/memory-layout' } ,
44- { text : '无锁队列' , link : '/zh/deep-dives/lock-free-queue' } ,
45- { text : 'SIMD 内部机制' , link : '/zh/deep-dives/simd-internals' } ,
46- ]
47-
48- const zhAlgorithmsItems = [
49- { text : '排序算法' , link : '/zh/algorithms/sorting' } ,
50- { text : '哈希算法' , link : '/zh/algorithms/hashing' } ,
51- ]
52-
53- const zhExerciseItems = [
54- { text : '内存练习' , link : '/zh/exercises/module-02-memory' } ,
55- { text : 'SIMD 练习' , link : '/zh/exercises/module-04-simd' } ,
56- { text : '并发练习' , link : '/zh/exercises/module-05-concurrency' } ,
57- { text : '解答' , link : '/zh/exercises/solutions' } ,
58- ]
59-
60- const zhReferenceItems = [
61- { text : '内存工具' , link : '/zh/reference/api/memory-utils' } ,
62- { text : 'SIMD Wrapper' , link : '/zh/reference/api/simd-wrapper' } ,
63- { text : 'Benchmark 工具' , link : '/zh/reference/api/benchmark-utils' } ,
64- { text : '常见问题' , link : '/zh/reference/faq' } ,
65- { text : '故障排查' , link : '/zh/reference/troubleshooting' } ,
66- ]
67-
68- export default withMermaid ( defineConfig ( {
14+ export default defineConfig ( {
6915 title : siteTitle ,
7016 description : siteDescription ,
7117 base,
7218 cleanUrls : false ,
7319 lastUpdated : true ,
74- mermaid : {
75- startOnLoad : false ,
76- securityLevel : 'strict' ,
77- flowchart : { useMaxWidth : true , htmlLabels : true } ,
78- sequence : { useMaxWidth : true } ,
79- gantt : { useMaxWidth : true } ,
80- theme : 'base' ,
81- themeVariables : {
82- fontFamily : 'Inter, system-ui, sans-serif' ,
83- fontSize : '14px' ,
84- } ,
85- } ,
8620 head : [
87- [ 'link' , { rel : 'icon' , type : 'image/svg+xml' , href : assetPath ( '/ logo.svg' ) } ] ,
21+ [ 'link' , { rel : 'icon' , type : 'image/svg+xml' , href : ` ${ base } logo.svg` } ] ,
8822 [ 'meta' , { name : 'theme-color' , content : '#3476f6' } ] ,
8923 [ 'meta' , { property : 'og:type' , content : 'website' } ] ,
9024 [ 'meta' , { property : 'og:site_name' , content : siteTitle } ] ,
9125 [ 'meta' , { property : 'og:title' , content : siteTitle } ] ,
9226 [ 'meta' , { property : 'og:description' , content : siteDescription } ] ,
93- [ 'meta' , { property : 'og:image' , content : canonicalAssetUrl ( '/og-card.png' ) } ] ,
94- [ 'meta' , { property : 'og:image:alt' , content : 'C++ 高性能指南文档社交卡片' } ] ,
9527 [ 'meta' , { property : 'og:locale' , content : 'zh_CN' } ] ,
96- [ 'meta' , { name : 'twitter:card' , content : 'summary_large_image' } ] ,
97- [ 'meta' , { name : 'twitter:image' , content : canonicalAssetUrl ( '/og-card.png' ) } ] ,
98- [ 'meta' , { name : 'twitter:title' , content : siteTitle } ] ,
99- [ 'meta' , { name : 'twitter:description' , content : siteDescription } ] ,
10028 [ 'meta' , { name : 'keywords' , content : 'C++, 性能, SIMD, 并发, CMake, 基准测试, 内存布局, 无锁队列' } ] ,
10129 ] ,
10230 locales : {
@@ -116,12 +44,10 @@ export default withMermaid(defineConfig({
11644 copyright : `版权所有 © ${ currentYear } C++ HPC Guide 贡献者` ,
11745 } ,
11846 nav : [
119- { text : '入门' , link : '/zh/getting-started/quickstart' , activeMatch : '/zh/getting-started/' } ,
120- { text : '指南' , link : '/zh/guides/learning-path' , activeMatch : '/zh/guides/' } ,
47+ { text : '入门' , link : '/zh/getting-started' , activeMatch : '/zh/getting-started' } ,
12148 { text : '深度专题' , link : '/zh/deep-dives/memory-layout' , activeMatch : '/zh/deep-dives/' } ,
122- { text : '算法' , link : '/zh/algorithms/sorting' , activeMatch : '/zh/algorithms/' } ,
123- { text : '练习' , link : '/zh/exercises/module-02-memory' , activeMatch : '/zh/exercises/' } ,
124- { text : '参考' , link : '/zh/reference/faq' , activeMatch : '/zh/reference/' } ,
49+ { text : '实战指南' , link : '/zh/guides/profiling' , activeMatch : '/zh/guides/' } ,
50+ { text : '参考' , link : '/zh/reference/api' , activeMatch : '/zh/reference/' } ,
12551 ] ,
12652 sidebar : {
12753 '/zh/' : [
@@ -133,27 +59,33 @@ export default withMermaid(defineConfig({
13359 } ,
13460 {
13561 text : '入门' ,
136- items : zhGettingStartedItems ,
137- } ,
138- {
139- text : '指南' ,
140- items : zhGuidesItems ,
62+ items : [
63+ { text : '快速开始' , link : '/zh/getting-started' } ,
64+ ] ,
14165 } ,
14266 {
14367 text : '深度专题' ,
144- items : zhDeepDivesItems ,
145- } ,
146- {
147- text : '算法' ,
148- items : zhAlgorithmsItems ,
68+ items : [
69+ { text : '内存布局与缓存' , link : '/zh/deep-dives/memory-layout' } ,
70+ { text : 'SIMD 向量化' , link : '/zh/deep-dives/simd-internals' } ,
71+ { text : '无锁并发' , link : '/zh/deep-dives/lock-free-queue' } ,
72+ { text : '现代 CMake 构建' , link : '/zh/deep-dives/cmake-build-system' } ,
73+ { text : 'C++20 性能实践' , link : '/zh/deep-dives/modern-cpp-perf' } ,
74+ ] ,
14975 } ,
15076 {
151- text : '练习' ,
152- items : zhExerciseItems ,
77+ text : '实战指南' ,
78+ items : [
79+ { text : '性能分析实战' , link : '/zh/guides/profiling' } ,
80+ { text : '优化决策手册' , link : '/zh/guides/optimization-playbook' } ,
81+ ] ,
15382 } ,
15483 {
15584 text : '参考' ,
156- items : zhReferenceItems ,
85+ items : [
86+ { text : 'API 参考' , link : '/zh/reference/api' } ,
87+ { text : '故障排查' , link : '/zh/reference/troubleshooting' } ,
88+ ] ,
15789 } ,
15890 ] ,
15991 } ,
@@ -179,23 +111,10 @@ export default withMermaid(defineConfig({
179111 search : { provider : 'local' } ,
180112 logo : {
181113 light : '/logo.svg' ,
182- dark : '/logo-dark .svg' ,
114+ dark : '/logo.svg' ,
183115 } ,
184116 socialLinks : [
185117 { icon : 'github' , link : 'https://github.com/LessUp/cpp-high-performance-guide' } ,
186118 ] ,
187119 } ,
188- vite : {
189- plugins : [ llmstxt ( ) ] ,
190- build : {
191- rollupOptions : {
192- output : {
193- manualChunks ( id ) {
194- if ( id . includes ( 'mermaid' ) ) return 'mermaid-lazy'
195- if ( id . includes ( 'katex' ) ) return 'katex-lazy'
196- } ,
197- } ,
198- } ,
199- } ,
200- } ,
201- } ) )
120+ } )
0 commit comments