Skip to content

Commit c482496

Browse files
committed
feat(docs): comprehensive Git Pages redesign with dark mode support
- Add Mermaid theme configuration for light/dark mode switching - Create dynamic theme switcher in theme/index.ts - Add GitHub icon dark mode CSS fix - Create SVG favicon with NVIDIA green branding - Add academic citation styles (citation, references-list, doi-link) - Add geek-style utilities (filename-tag, tech-badge, perf-highlight) - Create Citation.vue and PerfCompare.vue components - Add papers.md pages (EN/ZH) with academic references - Update sidebar navigation to include papers page The redesign provides: - Proper Mermaid chart rendering in both light and dark modes - Academic-style citations with DOI links - BibTeX export for academic writing - Performance comparison visualization components
1 parent a6a4477 commit c482496

10 files changed

Lines changed: 779 additions & 2 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
citeKey: string
4+
title: string
5+
authors: string
6+
year: string
7+
venue?: string
8+
doi?: string
9+
url?: string
10+
}>()
11+
</script>
12+
13+
<template>
14+
<div class="citation">
15+
<span class="citation-key">[{{ citeKey }}]</span>
16+
<span class="citation-title">{{ title }}</span>
17+
<span class="citation-authors"> — {{ authors }}</span>
18+
<span class="citation-year"> ({{ year }})</span>
19+
<span v-if="venue" class="citation-venue">, {{ venue }}</span>
20+
<div v-if="doi || url" class="citation-links">
21+
<a v-if="doi" :href="`https://doi.org/${doi}`" class="doi-link" target="_blank" rel="noopener">
22+
DOI: {{ doi }}
23+
</a>
24+
<a v-if="url" :href="url" target="_blank" rel="noopener">{{ url }}</a>
25+
</div>
26+
</div>
27+
</template>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
3+
4+
const props = defineProps<{
5+
data: { name: string; gflops: number; color?: string }[]
6+
baseline?: string
7+
}>()
8+
9+
const maxGflops = computed(() => Math.max(...props.data.map(d => d.gflops)))
10+
</script>
11+
12+
<template>
13+
<div class="perf-compare">
14+
<div v-for="item in data" :key="item.name" class="perf-row">
15+
<span class="perf-label">{{ item.name }}</span>
16+
<div class="perf-bar-container">
17+
<div
18+
class="perf-bar"
19+
:style="{
20+
width: `${(item.gflops / maxGflops) * 100}%`,
21+
background: item.color || 'var(--vp-c-brand-1)'
22+
}"
23+
/>
24+
<span class="perf-value">{{ item.gflops.toFixed(1) }} GFLOPS</span>
25+
</div>
26+
</div>
27+
</div>
28+
</template>

docs/.vitepress/config.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ export default withMermaid(defineConfig({
1717
head: [
1818
['meta', { name: 'theme-color', content: '#76b900' }],
1919
['meta', { property: 'og:type', content: 'website' }],
20+
['link', { rel: 'icon', type: 'image/svg+xml', href: '/sgemm-optimization/favicon.svg' }],
21+
['link', { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/sgemm-optimization/favicon-32x32.png' }],
22+
['link', { rel: 'apple-touch-icon', sizes: '180x180', href: '/sgemm-optimization/apple-touch-icon.png' }],
2023
],
2124

2225
ignoreDeadLinks: [
23-
// External links that VitePress can't verify at build time
2426
/^https?:\/\//,
2527
],
2628

@@ -70,6 +72,7 @@ export default withMermaid(defineConfig({
7072
items: [
7173
{ text: 'Resources Hub', link: '/en/resources/' },
7274
{ text: 'Further Reading Routes', link: '/en/resources/further-reading' },
75+
{ text: 'Related Papers & Research', link: '/en/resources/papers' },
7376
{ text: 'CUDA Memory Cheat Sheet', link: '/en/cuda-memory-cheatsheet' },
7477
{ text: 'Performance Casebook', link: '/en/performance-casebook' },
7578
{ text: 'Curated References', link: '/en/references' },
@@ -141,6 +144,7 @@ export default withMermaid(defineConfig({
141144
items: [
142145
{ text: '资源中心', link: '/zh/resources/' },
143146
{ text: '延伸阅读路线', link: '/zh/resources/further-reading' },
147+
{ text: '相关论文与研究', link: '/zh/resources/papers' },
144148
{ text: 'CUDA 内存速查表', link: '/zh/cuda-memory-cheatsheet' },
145149
{ text: '性能案例库', link: '/zh/performance-casebook' },
146150
{ text: '参考资料清单', link: '/zh/references' },
@@ -184,4 +188,20 @@ export default withMermaid(defineConfig({
184188
vite: {
185189
plugins: [llmstxt()],
186190
},
191+
192+
// Mermaid 配置 - 通过 withMermaid 传入
193+
mermaid: {
194+
startOnLoad: true,
195+
theme: 'base',
196+
themeVariables: {
197+
primaryColor: '#76b900',
198+
primaryTextColor: '#1b2117',
199+
primaryBorderColor: '#5a9200',
200+
lineColor: '#4f5b47',
201+
secondaryColor: '#f3f5f1',
202+
tertiaryColor: '#f0f2ed',
203+
fontSize: '14px',
204+
fontFamily: 'ui-sans-serif, system-ui, sans-serif',
205+
},
206+
},
187207
}))

docs/.vitepress/theme/index.ts

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,77 @@
11
import DefaultTheme from 'vitepress/theme'
22
import './style.css'
3+
import { watch, onMounted } from 'vue'
4+
import { useData } from 'vitepress'
5+
import Citation from '../components/Citation.vue'
6+
import PerfCompare from '../components/PerfCompare.vue'
37

4-
export default DefaultTheme
8+
export default {
9+
extends: DefaultTheme,
10+
enhanceApp({ app }) {
11+
app.component('Citation', Citation)
12+
app.component('PerfCompare', PerfCompare)
13+
},
14+
setup() {
15+
const { isDark } = useData()
16+
17+
// Mermaid 深浅色主题动态切换
18+
const updateMermaidTheme = async (dark: boolean) => {
19+
// 动态导入 mermaid
20+
const mermaid = (window as any).mermaid
21+
if (!mermaid) return
22+
23+
const themeVariables = dark ? {
24+
primaryColor: '#8bcd29',
25+
primaryTextColor: '#ebf0e6',
26+
primaryBorderColor: '#76b900',
27+
lineColor: '#b0b8aa',
28+
secondaryColor: '#141b13',
29+
tertiaryColor: '#1a2118',
30+
background: '#10140f',
31+
mainBkg: '#1a2118',
32+
fontSize: '14px',
33+
} : {
34+
primaryColor: '#76b900',
35+
primaryTextColor: '#1b2117',
36+
primaryBorderColor: '#5a9200',
37+
lineColor: '#4f5b47',
38+
secondaryColor: '#f3f5f1',
39+
tertiaryColor: '#f0f2ed',
40+
fontSize: '14px',
41+
}
42+
43+
mermaid.initialize({
44+
startOnLoad: true,
45+
theme: dark ? 'dark' : 'base',
46+
themeVariables,
47+
flowchart: {
48+
curve: 'basis',
49+
},
50+
sequence: {
51+
mirrorActors: false,
52+
},
53+
})
54+
55+
// 重新渲染所有 mermaid 图表
56+
const mermaidElements = document.querySelectorAll('.mermaid')
57+
mermaidElements.forEach((el) => {
58+
el.removeAttribute('data-processed')
59+
})
60+
61+
try {
62+
await mermaid.run({ querySelector: '.mermaid' })
63+
} catch (e) {
64+
console.warn('Mermaid re-render warning:', e)
65+
}
66+
}
67+
68+
onMounted(() => {
69+
// 初始化时设置主题
70+
updateMermaidTheme(isDark.value)
71+
})
72+
73+
watch(isDark, (dark) => {
74+
updateMermaidTheme(dark)
75+
})
76+
}
77+
}

0 commit comments

Comments
 (0)