Add SEO description support for categories#2554
Conversation
|
/deploy |
There was a problem hiding this comment.
Pull request overview
Adds support for an explicit SEO meta description on category pages, by introducing a seoDescription field in the TinaCMS category schema and surfacing it through the category GraphQL query into Next.js generateMetadata().
Changes:
- Add
seoDescriptionto the Tina “Category” collection schema (and regeneratetina-lock.json). - Extend
categoryWithRulesQueryto fetchseoDescription. - Update category page metadata generation to use
seoDescriptionwhen present.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tina/tina-lock.json | Regenerated Tina schema/GraphQL artifacts to include category seoDescription. |
| tina/queries/queries.gql | Fetches seoDescription in categoryWithRulesQuery. |
| tina/collection/category.tsx | Adds seoDescription field to the CategoryCategory template in the Tina collection config. |
| app/[filename]/page.tsx | Uses category seoDescription (if present) as the page meta description. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (category?.data?.category && "title" in category.data.category) { | ||
| return { | ||
| title: `${category.data.category.title} | SSW.Rules`, | ||
| const categoryData = category.data.category as any; | ||
| const metadata: any = { | ||
| title: `${categoryData.title} | SSW.Rules`, | ||
| alternates: { |
There was a problem hiding this comment.
In generateMetadata, the guard ("title" in category.data.category) doesn't actually narrow the Tina-generated union type (all category types have title), so the subsequent as any cast hides type errors and could break silently if getCategoryData ever returns a non-CategoryCategory. Prefer narrowing via __typename === "CategoryCategory" (or using the generated query types) and returning a properly typed Metadata object instead of any.
PR Preview Deployed
This preview will be automatically deleted when the PR is closed. |
Relates to #1620
This pull request introduces support for an SEO description field for categories, allowing category pages to include a custom meta description for improved search engine optimization.
SEO Description Support for Categories:
seoDescriptionfield to the category content model intina/collection/category.tsx, including UI configuration for editors.tina/queries/queries.gqlto fetch theseoDescriptionfield for categories.Metadata Generation Improvements:
generateMetadatafunction inapp/[filename]/page.tsxto include theseoDescriptionas the page description meta tag if it is present. (app/[filename]/page.tsxL340-R352)