Skip to content

Commit d7cc3ac

Browse files
committed
fix(seo): keep versioned landings renderable
1 parent 2ac55db commit d7cc3ac

6 files changed

Lines changed: 18 additions & 91 deletions

File tree

src/routes/-library-landing-route.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ export function beforeLoadLibraryLanding(
3131
throw redirect({ href: `/${libraryId}/latest`, statusCode: 308 })
3232
})
3333

34-
if (version === library.latestVersion) {
35-
throw redirect({
36-
href: href.replace(`/${libraryId}/${version}`, `/${libraryId}/latest`),
37-
statusCode: 308,
38-
})
39-
}
40-
4134
library.handleRedirects?.(href)
4235
}
4336

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { redirect, createFileRoute } from '@tanstack/react-router'
22

33
export const Route = createFileRoute('/_library/$libraryId/')({
4-
beforeLoad: ({ params, location }) => {
4+
beforeLoad: ({ params }) => {
55
throw redirect({
6-
href: location.href.replace(
7-
`/${params.libraryId}`,
8-
`/${params.libraryId}/latest`,
9-
),
10-
statusCode: 308,
6+
to: '/$libraryId/$version',
7+
params: { libraryId: params.libraryId, version: 'latest' } as never,
118
})
129
},
1310
})

src/utils/library-sitemap.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/utils/sitemap.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { getDocsManifest } from '~/utils/docs'
55
import { getPartnerSitemapEntries } from '~/utils/partner-pages'
66
import { SITE_URL } from '~/utils/site'
77
import { getChartsCatalogSitemapEntries } from './charts-catalog'
8-
import { getLibraryLandingSitemapEntries } from './library-sitemap'
98

109
export type SitemapEntry = {
1110
path: string
@@ -48,6 +47,20 @@ function asLastModified(value: string) {
4847
return new Date(`${value}T12:00:00.000Z`).toISOString()
4948
}
5049

50+
function getLibraryEntries(): Array<SitemapEntry> {
51+
return libraries.flatMap((library) => {
52+
if (
53+
library.visible === false ||
54+
!library.latestVersion ||
55+
library.sitemap?.includeLandingPage !== true
56+
) {
57+
return []
58+
}
59+
const basePath = `/${library.id}/latest`
60+
return [{ path: basePath }]
61+
})
62+
}
63+
5164
function isHighValueDocsSlug(slug: string) {
5265
const segments = slug.split('/').filter(Boolean)
5366

@@ -104,7 +117,7 @@ export async function getSitemapEntries(): Promise<Array<SitemapEntry>> {
104117

105118
const entries = [
106119
...HIGH_VALUE_NON_DOC_PAGES.map((path) => ({ path })),
107-
...getLibraryLandingSitemapEntries(),
120+
...getLibraryEntries(),
108121
...docsEntries.flat(),
109122
...getBlogEntries(),
110123
...getPartnerSitemapEntries(),

tests/library-landing-route.test.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/sitemap.test.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)