Skip to content

Commit 82b978d

Browse files
feat(navigation): add about page link in footer
主要变更: - 在 shared links 注册表中添加 about 页面入口 - 在站点页脚添加"关于 HagiCode"链接 - 新增测试验证链接注册和页脚展示 Co-Authored-By: Hagicode <noreply@hagicode.com> Signed-off-by: newbe36524 <newbe36524@qq.com>
1 parent 64d9989 commit 82b978d

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

Screenshot_20260331_113831.png

53.6 KB
Loading

shared/src/links.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ export const SITE_LINKS = {
125125
external: false,
126126
} as LinkConfig,
127127

128+
/** 官方 About 页面 */
129+
about: {
130+
dev: 'https://hagicode.com/about/',
131+
prod: 'https://hagicode.com/about/',
132+
external: false,
133+
} as LinkConfig,
134+
128135
/** 博客 RSS 订阅(相对于文档站点) */
129136
rss: {
130137
dev: 'http://localhost:31265/blog/rss.xml',

src/components/StarlightFooter.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const qqGroupLink = getLink('qqGroup');
2323
const discordLink = getLink('discord');
2424
const blogLink = getLink('blog');
2525
const productOverviewLink = getLink('productOverview');
26+
const aboutLink = getLink('about');
2627
const rssLink = getLink('rss');
2728
const costCalculatorLink = getLink('costCalculator');
2829
@@ -82,6 +83,7 @@ const discordRel = getLinkRel('discord');
8283
<h3 class="unified-footer-section-title">快速链接</h3>
8384
<nav class="unified-footer-section-links" aria-label="快速链接">
8485
<a href={desktopLink} class="unified-footer-link">下载客户端</a>
86+
<a href={aboutLink} class="unified-footer-link">关于 HagiCode</a>
8587
<a href="/installation/docker-compose" class="unified-footer-link">Docker Compose 安装</a>
8688
<a href={productOverviewLink} class="unified-footer-link">产品文档</a>
8789
<a href={blogLink} class="unified-footer-link">博客文章</a>

tests/about-footer-link.test.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import assert from 'node:assert/strict';
2+
import test from 'node:test';
3+
import { readFile } from 'node:fs/promises';
4+
import path from 'node:path';
5+
import { fileURLToPath } from 'node:url';
6+
7+
const testDir = path.dirname(fileURLToPath(import.meta.url));
8+
const docsRoot = path.resolve(testDir, '..');
9+
10+
function resolveDocsPath(relativePath) {
11+
return path.join(docsRoot, relativePath);
12+
}
13+
14+
test('docs link registry keeps a canonical about entry that points to the site-owned page', async () => {
15+
const linksSource = await readFile(resolveDocsPath('shared/src/links.ts'), 'utf8');
16+
17+
assert.match(
18+
linksSource,
19+
/about:\s*\{\s*dev:\s*'https:\/\/hagicode\.com\/about\/',\s*prod:\s*'https:\/\/hagicode\.com\/about\/'/s,
20+
);
21+
assert.equal(linksSource.includes('repos/site'), false);
22+
});
23+
24+
test('docs footer exposes the local about link entry without importing the site footer', async () => {
25+
const footerSource = await readFile(resolveDocsPath('src/components/StarlightFooter.astro'), 'utf8');
26+
27+
assert.match(footerSource, /const aboutLink = getLink\('about'\);/);
28+
assert.match(footerSource, /<a href=\{aboutLink\} class="unified-footer-link"> HagiCode<\/a>/);
29+
assert.equal(footerSource.includes('@/components/home/Footer'), false);
30+
assert.equal(footerSource.includes('repos/site'), false);
31+
});

0 commit comments

Comments
 (0)