Skip to content

Commit 713a4c3

Browse files
feat(docs): Quantum Cobalt v3.0 - Algorithms, theme-aware SVGs, semantic Mermaid
- Rewrite style.css as Quantum Cobalt v3.0 design system: - 5-layer surface system with refined OKLCH tokens - Subtle background grid pattern and glass morphism - Smooth dark/light theme transitions - Complete Mermaid semantic color classes (start/decision/action/complete/problem) - Fix theme-aware SVG bugs: - Split logo.svg into light/dark versions for VitePress class-based switching - Update og-card.svg to include Algorithms in navigation label - Add 4 new Vue components: - AlgorithmCard, ComplexityBadge, DiagramCanvas, ReferenceCard - Add standalone Algorithms module (en + zh): - Overview, Sorting, Hashing pages with academic Citation blocks - Upgrade Citation.vue with BibTeX copy button - Refactor optimization-decision-tree.md: - Remove all hard-coded Mermaid style commands - Use CSS semantic classes (:::) for light/dark-aware colors - Wrap all diagrams in DiagramCanvas component - Enhance Landing pages with Algorithms entry and technical specs table - Expand Research references with algorithm literature (Knuth, Sedgewick, Celis, F14) - Expand Related Work with hash table library comparisons Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent da26625 commit 713a4c3

22 files changed

Lines changed: 1906 additions & 485 deletions

‎docs/.vitepress/config.ts‎

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ const enResearchItems = [
7070
{ text: 'Evolution', link: '/en/research/evolution' },
7171
]
7272

73+
const enAlgorithmsItems = [
74+
{ text: 'Algorithms Overview', link: '/en/algorithms/' },
75+
{ text: 'Sorting', link: '/en/algorithms/sorting' },
76+
{ text: 'Hashing', link: '/en/algorithms/hashing' },
77+
]
78+
7379
const enDeepDivesItems = [
7480
{ text: 'Deep Dives Overview', link: '/en/deep-dives/' },
7581
{ text: 'Memory Layout', link: '/en/deep-dives/memory-layout' },
@@ -132,6 +138,12 @@ const zhContributingItems = [
132138
{ text: 'AI 开发流程', link: '/zh/contributing/ai-workflow' },
133139
]
134140

141+
const zhAlgorithmsItems = [
142+
{ text: '算法概览', link: '/zh/algorithms/' },
143+
{ text: '排序算法', link: '/zh/algorithms/sorting' },
144+
{ text: '哈希算法', link: '/zh/algorithms/hashing' },
145+
]
146+
135147
const zhDeepDivesItems = [
136148
{ text: '深度专题概览', link: '/zh/deep-dives/' },
137149
{ text: '内存布局(英文)', link: '/en/deep-dives/memory-layout' },
@@ -156,39 +168,15 @@ export default withMermaid(defineConfig({
156168
mermaid: {
157169
startOnLoad: false,
158170
securityLevel: 'strict',
159-
flowchart: { useMaxWidth: true },
171+
flowchart: { useMaxWidth: true, htmlLabels: true },
160172
sequence: { useMaxWidth: true },
161-
// Modern Geek Theme - Light Mode (Cobalt Engineering)
173+
gantt: { useMaxWidth: true },
174+
// Theme is fully controlled by CSS variables in style.css
175+
// for seamless light/dark mode switching.
162176
theme: 'base',
163177
themeVariables: {
164-
primaryColor: '#E8EDF5',
165-
primaryTextColor: '#1A2A4A',
166-
primaryBorderColor: '#3B6BDC',
167-
secondaryColor: '#F0F4FA',
168-
tertiaryColor: '#E8EDF5',
169-
lineColor: '#5A6A8A',
170178
fontFamily: 'Inter, system-ui, sans-serif',
171179
fontSize: '14px',
172-
nodeBorder: '#3B6BDC',
173-
mainBkg: '#E8EDF5',
174-
clusterBkg: '#F0F4FA',
175-
clusterBorder: '#3B6BDC',
176-
titleColor: '#1A2A4A',
177-
edgeLabelBackground: '#F0F4FA',
178-
actorBkg: '#E8EDF5',
179-
actorBorder: '#3B6BDC',
180-
actorTextColor: '#1A2A4A',
181-
actorLineColor: '#5A6A8A',
182-
signalColor: '#1A2A4A',
183-
signalTextColor: '#1A2A4A',
184-
labelBoxBkg: '#E8EDF5',
185-
labelBoxBorderColor: '#3B6BDC',
186-
labelTextColor: '#1A2A4A',
187-
loopTextColor: '#1A2A4A',
188-
noteBorderColor: '#5A6A8A',
189-
noteBkgColor: '#F0F4FA',
190-
activationBorderColor: '#3B6BDC',
191-
activationBkgColor: '#E8EDF5',
192180
},
193181
},
194182
head: [
@@ -220,6 +208,7 @@ export default withMermaid(defineConfig({
220208
nav: [
221209
{ text: 'Academy', link: '/en/academy/', activeMatch: '/en/academy/' },
222210
{ text: 'Architecture', link: '/en/architecture/', activeMatch: '/en/architecture/' },
211+
{ text: 'Algorithms', link: '/en/algorithms/', activeMatch: '/en/algorithms/' },
223212
{ text: 'Playbook', link: '/en/playbook/', activeMatch: '/en/playbook/|/en/getting-started/|/en/guides/' },
224213
{ text: 'Deep Dives', link: '/en/deep-dives/', activeMatch: '/en/deep-dives/' },
225214
{ text: 'Reference', link: '/en/reference/', activeMatch: '/en/reference/' },
@@ -242,6 +231,10 @@ export default withMermaid(defineConfig({
242231
text: 'Architecture',
243232
items: enArchitectureItems,
244233
},
234+
{
235+
text: 'Algorithms',
236+
items: enAlgorithmsItems,
237+
},
245238
{
246239
text: 'Playbook',
247240
items: enPlaybookItems,
@@ -296,6 +289,7 @@ export default withMermaid(defineConfig({
296289
nav: [
297290
{ text: '学院', link: '/zh/academy/', activeMatch: '/zh/academy/' },
298291
{ text: '架构', link: '/zh/architecture/', activeMatch: '/zh/architecture/' },
292+
{ text: '算法', link: '/zh/algorithms/', activeMatch: '/zh/algorithms/' },
299293
{ text: '实践手册', link: '/zh/playbook/', activeMatch: '/zh/playbook/|/zh/getting-started/|/zh/guides/' },
300294
{ text: '深度专题', link: '/zh/deep-dives/', activeMatch: '/zh/deep-dives/' },
301295
{ text: '参考', link: '/zh/reference/', activeMatch: '/zh/reference/' },
@@ -318,6 +312,10 @@ export default withMermaid(defineConfig({
318312
text: '架构',
319313
items: zhArchitectureItems,
320314
},
315+
{
316+
text: '算法',
317+
items: zhAlgorithmsItems,
318+
},
321319
{
322320
text: '实践手册',
323321
items: zhPlaybookItems,
@@ -366,7 +364,7 @@ export default withMermaid(defineConfig({
366364
search: { provider: 'local' },
367365
logo: {
368366
light: '/logo.svg',
369-
dark: '/logo.svg',
367+
dark: '/logo-dark.svg',
370368
},
371369
editLink: {
372370
pattern: 'https://github.com/LessUp/cpp-high-performance-guide/edit/master/docs/:path',
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<script setup lang="ts">
2+
interface AlgorithmLink {
3+
href: string
4+
label: string
5+
}
6+
7+
interface Props {
8+
title: string
9+
timeComplexity?: string
10+
spaceComplexity?: string
11+
description: string
12+
links?: AlgorithmLink[]
13+
}
14+
15+
defineProps<Props>()
16+
</script>
17+
18+
<template>
19+
<article class="wp-algorithm-card">
20+
<div class="wp-algorithm-card-header">
21+
<h3 class="wp-algorithm-card-title">{{ title }}</h3>
22+
</div>
23+
24+
<div class="wp-algorithm-card-complexity">
25+
<ComplexityBadge v-if="timeComplexity" :value="timeComplexity" label="Time" />
26+
<ComplexityBadge v-if="spaceComplexity" :value="spaceComplexity" label="Space" />
27+
</div>
28+
29+
<p class="wp-algorithm-card-desc">{{ description }}</p>
30+
31+
<div v-if="links?.length" class="wp-algorithm-card-links">
32+
<BaseAwareLink
33+
v-for="link in links"
34+
:key="`${link.href}:${link.label}`"
35+
class="wp-pill-link"
36+
:href="link.href"
37+
>
38+
{{ link.label }}
39+
</BaseAwareLink>
40+
</div>
41+
</article>
42+
</template>

‎docs/.vitepress/theme/Citation.vue‎

Lines changed: 47 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<script setup lang="ts">
2-
/**
3-
* Citation.vue - Academic citation system component
4-
*
5-
* Usage:
6-
* <Citation :references="[
7-
* { id: 'drepper2007', author: 'Drepper, U.', title: 'What Every Programmer Should Know About Memory', year: 2007, url: '...' }
8-
* ]" />
9-
*/
2+
import { ref } from 'vue'
103
114
interface Reference {
125
id: string
@@ -16,6 +9,7 @@ interface Reference {
169
source?: string
1710
url?: string
1811
doi?: string
12+
bibtex?: string
1913
}
2014
2115
interface Props {
@@ -29,13 +23,28 @@ const props = withDefaults(defineProps<Props>(), {
2923
numbered: true,
3024
})
3125
26+
const copiedId = ref<string | null>(null)
27+
3228
function formatCitation(ref: Reference): string {
3329
const parts = [ref.author]
3430
if (ref.year) parts.push(`(${ref.year})`)
3531
parts.push(`*${ref.title}*`)
3632
if (ref.source) parts.push(ref.source)
3733
return parts.join('. ')
3834
}
35+
36+
async function copyBibtex(ref: Reference) {
37+
if (!ref.bibtex) return
38+
try {
39+
await navigator.clipboard.writeText(ref.bibtex)
40+
copiedId.value = ref.id
41+
setTimeout(() => {
42+
if (copiedId.value === ref.id) copiedId.value = null
43+
}, 2000)
44+
} catch {
45+
// Silent fail on clipboard errors
46+
}
47+
}
3948
</script>
4049

4150
<template>
@@ -52,6 +61,21 @@ function formatCitation(ref: Reference): string {
5261
{{ ref.doi ? `DOI: ${ref.doi}` : 'Link' }}
5362
</a>
5463
</span>
64+
<button
65+
v-if="ref.bibtex"
66+
class="citation-copy-btn"
67+
@click="copyBibtex(ref)"
68+
:title="copiedId === ref.id ? 'Copied!' : 'Copy BibTeX'"
69+
>
70+
<svg v-if="copiedId === ref.id" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
71+
<polyline points="20 6 9 17 4 12" />
72+
</svg>
73+
<svg v-else width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
74+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
75+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
76+
</svg>
77+
{{ copiedId === ref.id ? 'Copied' : 'BibTeX' }}
78+
</button>
5579
</li>
5680
</ol>
5781
<ul v-else class="wp-citations-list">
@@ -65,75 +89,22 @@ function formatCitation(ref: Reference): string {
6589
{{ ref.doi ? `DOI: ${ref.doi}` : 'Link' }}
6690
</a>
6791
</span>
92+
<button
93+
v-if="ref.bibtex"
94+
class="citation-copy-btn"
95+
@click="copyBibtex(ref)"
96+
:title="copiedId === ref.id ? 'Copied!' : 'Copy BibTeX'"
97+
>
98+
<svg v-if="copiedId === ref.id" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
99+
<polyline points="20 6 9 17 4 12" />
100+
</svg>
101+
<svg v-else width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
102+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
103+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
104+
</svg>
105+
{{ copiedId === ref.id ? 'Copied' : 'BibTeX' }}
106+
</button>
68107
</li>
69108
</ul>
70109
</section>
71110
</template>
72-
73-
<style scoped>
74-
.wp-citations {
75-
margin: var(--wp-space-7, 3rem) 0;
76-
padding: var(--wp-space-5, 1.5rem);
77-
border: 1px solid var(--wp-line-1, #e0e0e0);
78-
border-radius: var(--wp-radius-2, 14px);
79-
background: var(--wp-surface-1, #f8f9fa);
80-
}
81-
82-
.wp-citations h3 {
83-
margin-top: 0;
84-
margin-bottom: var(--wp-space-4, 1rem);
85-
color: var(--wp-ink-1, #1a1a2e);
86-
font-size: 1.1rem;
87-
font-weight: 700;
88-
letter-spacing: -0.01em;
89-
}
90-
91-
.wp-citations-list {
92-
margin: 0;
93-
padding-left: var(--wp-space-5, 1.5rem);
94-
}
95-
96-
.wp-citation-item {
97-
margin-bottom: var(--wp-space-3, 0.75rem);
98-
color: var(--wp-ink-2, #4a4a6a);
99-
font-size: 0.95rem;
100-
line-height: 1.7;
101-
}
102-
103-
.wp-citation-item:last-child {
104-
margin-bottom: 0;
105-
}
106-
107-
.citation-author {
108-
font-weight: 600;
109-
color: var(--wp-ink-1, #1a1a2e);
110-
}
111-
112-
.citation-year {
113-
color: var(--wp-ink-3, #6a6a8a);
114-
}
115-
116-
.citation-title {
117-
font-style: italic;
118-
}
119-
120-
.citation-source {
121-
color: var(--wp-ink-3, #6a6a8a);
122-
}
123-
124-
.citation-link {
125-
margin-left: 0.5rem;
126-
}
127-
128-
.citation-link a {
129-
color: var(--wp-accent-primary, #3b6bdc);
130-
font-size: 0.85rem;
131-
text-decoration: none;
132-
transition: color 0.15s ease;
133-
}
134-
135-
.citation-link a:hover {
136-
color: var(--wp-accent-secondary, #5a8bfc);
137-
text-decoration: underline;
138-
}
139-
</style>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
3+
4+
interface Props {
5+
value: string
6+
label?: string
7+
}
8+
9+
const props = defineProps<Props>()
10+
11+
const className = computed(() => {
12+
const v = props.value.toLowerCase().trim()
13+
if (v === 'o(1)' || v === 'o(1)') return 'wp-complexity-badge--constant'
14+
if (v.includes('log')) return 'wp-complexity-badge--logarithmic'
15+
if (v === 'o(n)' || v === 'o(n)') return 'wp-complexity-badge--linear'
16+
if (v.includes('n log') || v.includes('nlog')) return 'wp-complexity-badge--linearithmic'
17+
if (v.includes('n²') || v.includes('n^2') || v.includes('n*n')) return 'wp-complexity-badge--quadratic'
18+
if (v.includes('2^n') || v.includes('exp')) return 'wp-complexity-badge--exponential'
19+
return 'wp-complexity-badge--linear'
20+
})
21+
</script>
22+
23+
<template>
24+
<span class="wp-complexity-badge" :class="className" :title="label ? `${label}: ${value}` : value">
25+
<template v-if="label">{{ label }}&nbsp;</template>{{ value }}
26+
</span>
27+
</template>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script setup lang="ts">
2+
interface Props {
3+
title?: string
4+
badge?: string
5+
caption?: string
6+
}
7+
8+
defineProps<Props>()
9+
</script>
10+
11+
<template>
12+
<figure class="wp-diagram-canvas">
13+
<div v-if="title || badge" class="wp-diagram-canvas-header">
14+
<span v-if="title" class="wp-diagram-canvas-title">{{ title }}</span>
15+
<span v-if="badge" class="wp-diagram-canvas-badge">{{ badge }}</span>
16+
</div>
17+
<div class="wp-diagram-canvas-body">
18+
<slot />
19+
</div>
20+
<figcaption v-if="caption" class="wp-diagram-canvas-footer">
21+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
22+
<circle cx="12" cy="12" r="10"/>
23+
<line x1="12" y1="16" x2="12" y2="12"/>
24+
<line x1="12" y1="8" x2="12.01" y2="8"/>
25+
</svg>
26+
{{ caption }}
27+
</figcaption>
28+
</figure>
29+
</template>

0 commit comments

Comments
 (0)