-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix(blog): apply proper route to metadata call #8224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where blog pages were using the incorrect metadata generation route. The change ensures that blog-specific metadata is properly generated by creating a dedicated generateBlogMetadata
function that includes the blog
prefix in the route path.
- Creates a new
generateBlogMetadata
function that properly constructs blog metadata routes - Updates blog pages to use the new blog-specific metadata generation function
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
apps/site/next.dynamic.page.mjs | Adds new generateBlogMetadata function with proper blog route handling |
apps/site/app/[locale]/blog/[...path]/page.tsx | Updates blog pages to use the new blog-specific metadata function |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8224 +/- ##
==========================================
- Coverage 76.43% 76.39% -0.05%
==========================================
Files 115 115
Lines 9643 9643
Branches 316 317 +1
==========================================
- Hits 7371 7367 -4
- Misses 2271 2275 +4
Partials 1 1 ☔ View full report in Codecov by Sentry. |
* @param {{ params: Promise<{ path: Array<string>; locale: string }> }} props | ||
* @returns {Promise<import('next').Metadata>} the metadata for the page | ||
*/ | ||
export const generateBlogMetadata = async props => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, can we make an overload of generateMetadata that supports path prefixes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/**
* This generates each page's HTML Metadata
*
* @see https://nextjs.org/docs/app/api-reference/functions/generate-metadata
*
* @param {{ params: Promise<{ path: Array<string>; locale: string; prefix?: string }> }} props
* @returns {Promise<import('next').Metadata>} the metadata for the page
*/
export const generateMetadata = async props => {
const { path = [], prefix = '', locale = defaultLocale.code } = await props.params;
const pathname = dynamicRouter.getPathname(path);
return dynamicRouter.getPageMetadata(locale, `${prefix}${pathname}`);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then usage:
// This generates each page's HTML Metadata
// @see https://nextjs.org/docs/app/api-reference/functions/generate-metadata
export const generateMetadata = props => basePage.generateMetadata({ ...props, prefix: 'blog' });
Description
The base generateMetadata function is not taking
/blog
into account.I don't quite understand this next convention and the params type and how it relates to our code -
/blog
is not coming in on the initial entrypoint.This is also affecting the download archive logic. Perhaps we can code-golf a solution that doesn't require duplication.
Live at https://nodejs.org/en/download/archive/v24.10.0
Validation
View title at https://nodejs-org-git-8223-blog-title-openjs.vercel.app/en/blog/release/v24.10.0
Related Issues
Check List
pnpm format
to ensure the code follows the style guide.pnpm test
to check if all tests are passing.pnpm build
to check if the website builds without errors.