Skip to content

Commit b11e6fd

Browse files
fix(seo): use canonical Charts catalog URLs in the sitemap (#1469)
* fix(seo): emit canonical Charts catalog sitemap URLs * fix(seo): keep the catalog fallback URL canonical
1 parent d72c534 commit b11e6fd

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎src/utils/charts-catalog.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export function getChartsCatalogSitemapEntries(index: ChartsCatalogIndex) {
6060
)
6161

6262
return [
63-
{ path: chartsCatalogBasePath },
63+
{ path: chartsCatalogBasePath.replace(/\/$/, '') },
6464
...collections.map((collection) => ({
65-
path: `${chartsCatalogBasePath}collections/${collection.id}/`,
65+
path: `${chartsCatalogBasePath}collections/${collection.id}`,
6666
})),
6767
...index.cases.map((catalogCase) => ({
68-
path: `${chartsCatalogBasePath}charts/${catalogCase.id}/`,
68+
path: `${chartsCatalogBasePath}charts/${catalogCase.id}`,
6969
})),
7070
]
7171
}

‎src/utils/sitemap.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async function getPublishedChartsCatalogEntries(): Promise<
145145
return getChartsCatalogSitemapEntries(publication.index)
146146
} catch (error) {
147147
console.error('[sitemap] Charts catalog unavailable', error)
148-
return [{ path: '/charts/catalog/' }]
148+
return [{ path: '/charts/catalog' }]
149149
}
150150
}
151151

‎tests/charts-catalog-site-contracts.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type DocsWebhookSource,
1313
} from '../src/utils/docs-webhook-sources'
1414

15-
test('sitemap exposes catalog pages but not runtime resources', () => {
15+
test('sitemap emits canonical catalog URLs without trailing slashes or runtime resources', () => {
1616
const index = parseChartsCatalogIndex({
1717
schemaVersion: 2,
1818
source: {
@@ -46,9 +46,9 @@ test('sitemap exposes catalog pages but not runtime resources', () => {
4646
})
4747

4848
assert.deepEqual(getChartsCatalogSitemapEntries(index), [
49-
{ path: '/charts/catalog/' },
50-
{ path: '/charts/catalog/collections/shadcn/' },
51-
{ path: '/charts/catalog/charts/01-line/' },
49+
{ path: '/charts/catalog' },
50+
{ path: '/charts/catalog/collections/shadcn' },
51+
{ path: '/charts/catalog/charts/01-line' },
5252
])
5353
})
5454

0 commit comments

Comments
 (0)