Skip to content

Commit ef7c0b1

Browse files
committed
fix(blog): thread route id through buildAuthorMetadata for canonical URL
Author pages for unknown/unmatched ids fell back to author?.id, which is undefined when no post matches — collapsing canonical/OG URLs to {basePath}/authors/ instead of {basePath}/authors/{id}. Pass the route id explicitly so canonical always resolves correctly.
1 parent da5fb6c commit ef7c0b1

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function generateMetadata({
1212
}): Promise<Metadata> {
1313
const { id } = await params
1414
const posts = (await getAllPostMeta()).filter((p) => p.author.id === id)
15-
return buildAuthorMetadata(posts[0]?.author)
15+
return buildAuthorMetadata(id, posts[0]?.author)
1616
}
1717

1818
export default async function AuthorPage({ params }: { params: Promise<{ id: string }> }) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function generateMetadata({
1212
}): Promise<Metadata> {
1313
const { id } = await params
1414
const posts = (await getAllPostMeta()).filter((p) => p.author.id === id)
15-
return buildAuthorMetadata(posts[0]?.author)
15+
return buildAuthorMetadata(id, posts[0]?.author)
1616
}
1717

1818
export default async function AuthorPage({ params }: { params: Promise<{ id: string }> }) {

apps/sim/lib/blog/seo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export function buildTagsBreadcrumbJsonLd() {
4141
return buildTagsBreadcrumbJsonLdGeneric(BLOG_SECTION)
4242
}
4343

44-
export function buildAuthorMetadata(author?: Author) {
45-
return buildAuthorMetadataGeneric(BLOG_SECTION, author)
44+
export function buildAuthorMetadata(id: string, author?: Author) {
45+
return buildAuthorMetadataGeneric(BLOG_SECTION, id, author)
4646
}
4747

4848
export function buildAuthorGraphJsonLd(author: Author) {

apps/sim/lib/content/seo.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,13 @@ export function buildTagsBreadcrumbJsonLd(section: ContentSection) {
270270
}
271271
}
272272

273-
export function buildAuthorMetadata(section: ContentSection, author?: Author): Metadata {
273+
export function buildAuthorMetadata(
274+
section: ContentSection,
275+
id: string,
276+
author?: Author
277+
): Metadata {
274278
const name = author?.name ?? 'Author'
275-
const canonical = `${SITE_URL}${section.basePath}/authors/${author?.id ?? ''}`
279+
const canonical = `${SITE_URL}${section.basePath}/authors/${id}`
276280
const description = `Read articles by ${name} on the Sim ${section.name.toLowerCase()}.`
277281
return {
278282
title: `${name} | Sim ${section.name}`,

apps/sim/lib/library/seo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export function buildTagsBreadcrumbJsonLd() {
4242
return buildTagsBreadcrumbJsonLdGeneric(LIBRARY_SECTION)
4343
}
4444

45-
export function buildAuthorMetadata(author?: Author) {
46-
return buildAuthorMetadataGeneric(LIBRARY_SECTION, author)
45+
export function buildAuthorMetadata(id: string, author?: Author) {
46+
return buildAuthorMetadataGeneric(LIBRARY_SECTION, id, author)
4747
}
4848

4949
export function buildAuthorGraphJsonLd(author: Author) {

0 commit comments

Comments
 (0)