Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: make pageBuilder more defensive when loading titles and slugs
  • Loading branch information
robinbaxon committed Nov 26, 2025
commit 66ba73c186ac5f3a8f2f434d2ab3a2289479318b
23 changes: 11 additions & 12 deletions studio/schemas/documents/pageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,18 @@ const pageBuilder = defineType({
slug: titleSlug.name,
},
prepare({ title, slug }) {
if (!isInternationalizedString(title)) {
throw new TypeError(
`Expected 'title' to be InternationalizedString, was ${typeof title}`,
);
}
if (!isInternationalizedString(slug)) {
throw new TypeError(
`Expected 'slug' to be InternationalizedString, was ${typeof slug}`,
);
}
// Handle cases where the field might not be properly initialized yet
const titleText = isInternationalizedString(title)
? (firstTranslation(title) ?? undefined)
: undefined;

const slugText = isInternationalizedString(slug)
? (firstTranslation(slug) ?? undefined)
: undefined;

return {
title: firstTranslation(title) ?? undefined,
subtitle: firstTranslation(slug) ?? undefined,
title: titleText || "Untitled",
subtitle: slugText,
};
},
},
Expand Down