Skip to content

Commit 1a045b1

Browse files
committed
fix(docs): resolve GitHub Pages base-path bug in LandingHero and sync stale tests
LandingHero links rendered raw hrefs without the VitePress base prefix, breaking all CTA buttons on GitHub Pages (/en/... instead of /cpp-high-performance-guide/en/...). Added withBase() resolution to match BaseAwareLink's pattern. Also sync tests that drifted during the Quantum Cobalt v4.0 refactor: - CSS token checks now read tokens/ subdirectory files - Token names updated to current naming (--wp-surface-meta, etc.) - LandingHero replaces SectionHero/MetricStrip assertions - Case-sensitive match for Debug→UBSan - Language-switch hrefs moved to nav LanguageSwitcher
1 parent 6a3b12b commit 1a045b1

3 files changed

Lines changed: 43 additions & 24 deletions

File tree

docs/.vitepress/tests/theme-primitives.test.mjs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ function read(relativePath) {
1515
return fs.readFileSync(path.join(themeDir, relativePath), 'utf8')
1616
}
1717

18+
function readAllCss() {
19+
const mainCss = read('style.css')
20+
const tokensDir = path.join(themeDir, 'tokens')
21+
let allCss = mainCss
22+
23+
if (fs.existsSync(tokensDir)) {
24+
const tokenFiles = fs.readdirSync(tokensDir).filter(f => f.endsWith('.css'))
25+
for (const file of tokenFiles) {
26+
allCss += '\n' + fs.readFileSync(path.join(tokensDir, file), 'utf8')
27+
}
28+
}
29+
30+
return allCss
31+
}
32+
1833
function extractHeroLinks(content) {
1934
const linksMatch = content.match(/:links='\[(.*?)\]'/s)
2035
assert.ok(linksMatch, 'expected SectionHero links array')
@@ -64,19 +79,16 @@ export default component`
6479
}
6580

6681
test('style.css keeps tokenized selectors for the live homepage, Mermaid, and SVG surfaces', () => {
67-
const css = read('style.css')
82+
const css = readAllCss()
6883

6984
for (const token of [
7085
'--wp-paper-1',
7186
'--wp-ink-1',
72-
'--wp-panel-bg',
73-
'--wp-figure-bg',
74-
'--wp-meta-bg',
75-
'--wp-section-index-bg',
76-
'--wp-section-index-border',
87+
'--wp-surface-meta',
88+
'--wp-surface-figure',
89+
'--wp-surface-section-index',
7790
'--wp-surface-1',
7891
'--wp-surface-2',
79-
'--wp-surface-section-index',
8092
'--wp-pill-bg',
8193
'--wp-diagram-stroke',
8294
'--wp-icon-muted',
@@ -125,7 +137,7 @@ test('language switcher markup keeps native navigation when JavaScript is unavai
125137
test('theme index wires only the active language chrome', () => {
126138
const themeIndex = read('index.ts')
127139

128-
for (const componentName of ['BaseAwareLink', 'LanguageRedirect', 'LanguageSwitcher', 'SectionHero', 'MetricStrip', 'SectionIndex']) {
140+
for (const componentName of ['BaseAwareLink', 'LanguageRedirect', 'LanguageSwitcher', 'SectionHero', 'MetricStrip', 'SectionIndex', 'LandingHero']) {
129141
assert.match(themeIndex, new RegExp(componentName))
130142
}
131143
})
@@ -136,25 +148,23 @@ test('bilingual landing pages preserve copy while using shared whitepaper primit
136148
const zhIndex = fs.readFileSync(path.join(docsRoot, 'zh', 'index.md'), 'utf8')
137149

138150
for (const content of [enIndex, zhIndex]) {
139-
assert.match(content, /<SectionHero\b/)
140-
assert.match(content, /<MetricStrip\b/)
151+
// LandingHero is used instead of SectionHero+MetricStrip in current implementation
152+
assert.match(content, /<LandingHero\b/)
141153
assert.match(content, /<SectionIndex\b/)
142154
assert.doesNotMatch(content, /class="home-header"/)
143155
assert.doesNotMatch(content, /class="home-intro-row"/)
144156
assert.doesNotMatch(content, /class="feature-map"/)
145157
}
146158

147-
assert.match(enIndex, /title="C\+\+ High Performance Guide"/)
159+
assert.match(enIndex, /title="High Performance"/)
160+
assert.match(enIndex, /titleAccent="C\+\+ Guide"/)
148161
assert.match(enIndex, /This repository treats performance advice as something to compile, test, benchmark, and falsify\./)
149162
assert.match(enIndex, /title="Quick Start"/)
150-
assert.match(zhIndex, /title="C\+\+ "/)
163+
assert.match(zhIndex, /title=""/)
164+
assert.match(zhIndex, /titleAccent="C\+\+ "/)
151165
assert.match(zhIndex, //)
152166
assert.match(zhIndex, /title=""/)
153-
assert.match(enIndex, /links-aria-label="Landing page links"/)
154-
assert.match(enIndex, /aria-label="Project metrics"/)
155-
assert.match(zhIndex, /links-aria-label=""/)
156-
assert.match(zhIndex, /aria-label=""/)
157-
assert.match(read('SectionHero.vue'), /BaseAwareLink/)
167+
// links-aria-label and aria-label are now in LandingHero component props
158168
assert.match(read('SectionIndex.vue'), /BaseAwareLink/)
159169

160170
for (const href of [
@@ -169,7 +179,6 @@ test('bilingual landing pages preserve copy while using shared whitepaper primit
169179
'/en/guides/optimization-decision-tree',
170180
'/en/guides/validation',
171181
'/en/guides/best-practices',
172-
'/zh/',
173182
]) {
174183
assert.match(enIndex, new RegExp(`href: "${href.replaceAll('/', '\\/')}"`))
175184
}
@@ -186,7 +195,6 @@ test('bilingual landing pages preserve copy while using shared whitepaper primit
186195
'/zh/guides/optimization-decision-tree',
187196
'/zh/guides/validation',
188197
'/zh/guides/best-practices',
189-
'/en/',
190198
]) {
191199
assert.match(zhIndex, new RegExp(`href: "${href.replaceAll('/', '\\/')}"`))
192200
}

docs/.vitepress/tests/whitepaper-content.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test('landing page states the stronger thesis and validation ladder', () => {
6262
const content = read('en/index.md')
6363

6464
assert.match(content, /performance advice as something to compile, test, benchmark, and falsify/i)
65-
assert.match(content, /debugubsan/)
65+
assert.match(content, /DebugUBSan/)
6666
assert.match(content, /Validation claims/)
6767
assert.match(content, /Expert reader callouts/)
6868
})

docs/.vitepress/theme/LandingHero.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
2-
import { ref, onMounted } from 'vue'
2+
import { ref, onMounted, computed } from 'vue'
3+
import { withBase } from 'vitepress'
34
45
interface HeroLink {
56
href: string
@@ -23,6 +24,16 @@ const props = defineProps<{
2324
2425
const isVisible = ref(false)
2526
27+
// Resolve links with base path for GitHub Pages compatibility
28+
const resolvedLinks = computed(() => {
29+
return props.links?.map(link => ({
30+
...link,
31+
resolvedHref: /^(?:[a-z]+:|\/\/|#)/i.test(link.href)
32+
? link.href
33+
: withBase(link.href)
34+
}))
35+
})
36+
2637
onMounted(() => {
2738
// Trigger entrance animation after mount
2839
requestAnimationFrame(() => {
@@ -59,11 +70,11 @@ onMounted(() => {
5970
<p class="landing-hero__subtitle">{{ subtitle }}</p>
6071

6172
<!-- Action links -->
62-
<nav v-if="links?.length" class="landing-hero__actions">
73+
<nav v-if="resolvedLinks?.length" class="landing-hero__actions">
6374
<a
64-
v-for="link in links"
75+
v-for="link in resolvedLinks"
6576
:key="link.href"
66-
:href="link.href"
77+
:href="link.resolvedHref"
6778
class="landing-hero__cta"
6879
:class="{ 'landing-hero__cta--primary': link.primary }"
6980
>

0 commit comments

Comments
 (0)