feat(theme): 六类页面渲染与路由分派
单一动态路由 [...slug].astro 读 routes.json html 纯路径行分派六模板 (home/typeKey 详情/分类前缀列表/news 主列表),无法分派即构建明错; 404 独立静态页。夹具扩展为六页集(真实 hesupipe 抽样形状脱敏化: knownFields.postDate/title、media 块 attachmentRefs.* fieldPath、 /products/ 内容页占据、编码路径 + .html 字面路径防御)。 字面 .html 路径对齐钩子(astro.config 内联 integration):Astro 页面 产物在 directory/file/preserve 三态均产不出 dist/news/x.html 字面文件, 构建收尾把包装目录折平为字面文件——target_file 契约对齐。 构建级测试 8 例(render-cases):全量映射/编码字节原样/首页截断/ 产品参数相册/新闻字面 .html/列表两类/SEO 基线。372 → 380。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -34,14 +34,16 @@ describe('load-render-data(渲染数据唯一入口)', () => {
|
||||
expect(data.site.locale).toBe('zh-CN')
|
||||
expect(data.site.brand).toStrictEqual({})
|
||||
|
||||
expect(data.contents).toHaveLength(3)
|
||||
// Task 4 扩夹后:11 条(3 basic_page + 4 news_article + 4 product)——六页集 + 首页截断断言的第 4 条
|
||||
expect(data.contents).toHaveLength(11)
|
||||
const news = data.contents.find((c) => c.slug === 'fixture-news-a')
|
||||
expect(news?.typeKey).toBe('news_article')
|
||||
expect(news?.data.bodyHtml).toContain('src="/wp-content/uploads/2026/10/fixture-a.png"')
|
||||
expect(news?.media?.featured).toBe('/wp-content/uploads/2026/10/fixture-a.png')
|
||||
// media 块键 = media_usages 真实 fieldPath(Task 2 物化面),非裸 'featured'
|
||||
expect(news?.media?.['attachmentRefs.featured']).toBe('/wp-content/uploads/2026/10/fixture-a.png')
|
||||
|
||||
expect(data.taxonomies[0]).toMatchObject({ key: 'product-category', objectType: 'product' })
|
||||
expect(data.taxonomies[0]?.terms[0]?.contentEntryIds).toHaveLength(1)
|
||||
expect(data.taxonomies[0]?.terms[0]?.contentEntryIds).toHaveLength(4)
|
||||
|
||||
const redirect = data.routes.find((r) => r.routeKind === 'redirect')
|
||||
expect(redirect).toMatchObject({
|
||||
@@ -51,7 +53,7 @@ describe('load-render-data(渲染数据唯一入口)', () => {
|
||||
indexable: false,
|
||||
})
|
||||
|
||||
expect(data.assets.size).toBe(1)
|
||||
expect(data.assets.size).toBe(3)
|
||||
expect(data.assets.get('/wp-content/uploads/2026/10/fixture-a.png')).toMatchObject({
|
||||
detectedMimeType: 'image/png',
|
||||
byteSize: 1234,
|
||||
@@ -60,7 +62,7 @@ describe('load-render-data(渲染数据唯一入口)', () => {
|
||||
altText: null,
|
||||
})
|
||||
|
||||
expect(data.renderManifest.counts).toStrictEqual({ contents: 3, taxonomies: 1, routes: 7, assets: 1 })
|
||||
expect(data.renderManifest.counts).toStrictEqual({ contents: 11, taxonomies: 1, routes: 15, assets: 3 })
|
||||
expect(data.renderManifest.renderSnapshotVersion).toBe(1)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user