Skip to content

Commit c19db87

Browse files
authored
fix(landing): return 404 for unknown library, blog, integration, model, and author slugs (#8587)
* fix(landing): return 404 for unknown library, blog, integration, model, and author slugs * fix(landing): pre-render reseller model pages so they keep resolving
1 parent 78c371e commit c19db87

9 files changed

Lines changed: 65 additions & 20 deletions

File tree

‎apps/docs/app/sitemap.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ import { DOCS_BASE_URL } from '@/lib/urls'
55
export const revalidate = 3600
66

77
export default function sitemap(): MetadataRoute.Sitemap {
8-
return source.getPages().map((page) => ({
9-
url: `${DOCS_BASE_URL}${page.url}`,
10-
lastModified: 'lastModified' in page.data ? page.data.lastModified : undefined,
11-
}))
8+
// The docs root redirects to /introduction, which is listed on its own.
9+
return source
10+
.getPages()
11+
.filter((page) => page.url !== '/')
12+
.map((page) => ({
13+
url: `${DOCS_BASE_URL}${page.url}`,
14+
lastModified: 'lastModified' in page.data ? page.data.lastModified : undefined,
15+
}))
1216
}

‎apps/sim/app/(landing)/blog/[slug]/page.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { getAllPostMeta, getPostBySlug, getRelatedPosts } from '@/lib/blog/regis
44
import { BLOG_SECTION, buildPostGraphJsonLd, buildPostMetadata } from '@/lib/blog/seo'
55
import { ContentPostPage } from '@/app/(landing)/components'
66

7-
/** Unknown slugs reach the section 404 while known pages remain pre-rendered. */
8-
export const dynamicParams = true
7+
/**
8+
* Unknown params must 404 before rendering: `notFound()` during render streams this segment's
9+
* `loading.tsx` with a 200 status first.
10+
*/
11+
export const dynamicParams = false
912

1013
export async function generateStaticParams() {
1114
const posts = await getAllPostMeta()

‎apps/sim/app/(landing)/blog/authors/[id]/page.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ import { ContentAuthorPage } from '@/app/(landing)/components'
66

77
export const revalidate = 3600
88

9+
/**
10+
* Unknown params must 404 before rendering: `notFound()` during render streams this segment's
11+
* `loading.tsx` with a 200 status first.
12+
*/
13+
export const dynamicParams = false
14+
15+
export async function generateStaticParams() {
16+
const ids = new Set((await getAllPostMeta()).flatMap((p) => p.authors.map((a) => a.id)))
17+
return [...ids].map((id) => ({ id }))
18+
}
19+
920
export async function generateMetadata({
1021
params,
1122
}: {

‎apps/sim/app/(landing)/integrations/(shell)/[slug]/page.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ const MAX_TEMPLATES_SHOWN = 12
4747
const bySlug = new Map(allIntegrations.map((i) => [i.slug, i]))
4848
const byType = new Map(allIntegrations.map((i) => [i.type, i]))
4949

50-
/** Unknown slugs reach the section 404 while known pages remain pre-rendered. */
51-
export const dynamicParams = true
50+
/**
51+
* Unknown params must 404 before rendering: `notFound()` during render streams this segment's
52+
* `loading.tsx` with a 200 status first.
53+
*/
54+
export const dynamicParams = false
5255

5356
/**
5457
* Returns up to `limit` related integration slugs from the same category, so

‎apps/sim/app/(landing)/library/[slug]/page.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import { ComparisonLinks } from '@/app/(landing)/comparisons/components/comparis
66
import { getComparisonsForPost } from '@/app/(landing)/comparisons/library-links'
77
import { ContentPostPage } from '@/app/(landing)/components'
88

9-
/** Unknown slugs reach the section 404 while known pages remain pre-rendered. */
10-
export const dynamicParams = true
9+
/**
10+
* Unknown params must 404 before rendering: `notFound()` during render streams this segment's
11+
* `loading.tsx` with a 200 status first.
12+
*/
13+
export const dynamicParams = false
1114

1215
export async function generateStaticParams() {
1316
const posts = await getAllPostMeta()

‎apps/sim/app/(landing)/library/authors/[id]/page.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ import { ContentAuthorPage } from '@/app/(landing)/components'
66

77
export const revalidate = 3600
88

9+
/**
10+
* Unknown params must 404 before rendering: `notFound()` during render streams this segment's
11+
* `loading.tsx` with a 200 status first.
12+
*/
13+
export const dynamicParams = false
14+
15+
export async function generateStaticParams() {
16+
const ids = new Set((await getAllPostMeta()).flatMap((p) => p.authors.map((a) => a.id)))
17+
return [...ids].map((id) => ({ id }))
18+
}
19+
920
export async function generateMetadata({
1021
params,
1122
}: {

‎apps/sim/app/(landing)/models/(shell)/[provider]/[model]/page.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { LANDING_CONTENT_WIDTH, LANDING_GUTTER } from '@/app/(landing)/component
1010
import { ShareButton } from '@/app/(landing)/components/share-button'
1111
import { FeaturedModelCard, ProviderIcon } from '@/app/(landing)/models/components/model-primitives'
1212
import {
13-
ALL_CATALOG_MODELS,
1413
buildModelCapabilityFacts,
1514
buildModelFaqs,
1615
formatPrice,
@@ -21,18 +20,21 @@ import {
2120
getPricingBounds,
2221
getProviderBySlug,
2322
getRelatedModels,
23+
MODEL_PROVIDERS_WITH_MODELS,
2424
} from '@/app/(landing)/models/utils'
2525

2626
const baseUrl = SITE_URL
2727

28-
/** Unknown slugs reach the section 404 while known pages remain pre-rendered. */
29-
export const dynamicParams = true
28+
/**
29+
* Unknown params must 404 before rendering: `notFound()` during render streams this segment's
30+
* `loading.tsx` with a 200 status first.
31+
*/
32+
export const dynamicParams = false
3033

3134
export async function generateStaticParams() {
32-
return ALL_CATALOG_MODELS.map((model) => ({
33-
provider: model.providerSlug,
34-
model: model.slug,
35-
}))
35+
return MODEL_PROVIDERS_WITH_MODELS.flatMap((provider) =>
36+
provider.models.map((model) => ({ provider: provider.slug, model: model.slug }))
37+
)
3638
}
3739

3840
export async function generateMetadata({

‎apps/sim/app/(landing)/models/(shell)/[provider]/page.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ import {
1919
formatTokenCount,
2020
getProviderBySlug,
2121
MODEL_PROVIDERS_WITH_CATALOGS,
22+
MODEL_PROVIDERS_WITH_MODELS,
2223
TOP_MODEL_PROVIDERS,
2324
} from '@/app/(landing)/models/utils'
2425

2526
const baseUrl = SITE_URL
2627

27-
/** Unknown slugs reach the section 404 while known pages remain pre-rendered. */
28-
export const dynamicParams = true
28+
/**
29+
* Unknown params must 404 before rendering: `notFound()` during render streams this segment's
30+
* `loading.tsx` with a 200 status first.
31+
*/
32+
export const dynamicParams = false
2933

3034
export async function generateStaticParams() {
31-
return MODEL_PROVIDERS_WITH_CATALOGS.map((provider) => ({
35+
return MODEL_PROVIDERS_WITH_MODELS.map((provider) => ({
3236
provider: provider.slug,
3337
}))
3438
}

‎apps/sim/app/(landing)/models/utils.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ function assertUniqueGeneratedRoutes(providers: CatalogProvider[]): void {
578578
assertUniqueGeneratedRoutes(rawProviders)
579579

580580
export const MODEL_CATALOG_PROVIDERS: CatalogProvider[] = rawProviders
581+
/** Every provider with a page: those with a model catalog, resellers included. */
582+
export const MODEL_PROVIDERS_WITH_MODELS = MODEL_CATALOG_PROVIDERS.filter(
583+
(provider) => provider.models.length > 0
584+
)
581585
export const MODEL_PROVIDERS_WITH_CATALOGS = MODEL_CATALOG_PROVIDERS.filter(
582586
(provider) => provider.models.length > 0 && !provider.isReseller
583587
)

0 commit comments

Comments
 (0)