Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
6 changes: 5 additions & 1 deletion apps/site/app/[locale]/blog/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export const generateViewport = basePage.generateViewport;

// This generates each page's HTML Metadata
// @see https://nextjs.org/docs/app/api-reference/functions/generate-metadata
export const generateMetadata = basePage.generateMetadata;
export const generateMetadata = ({
params,
}: {
params: Promise<{ path: Array<string>; locale: string }>;
Comment thread
avivkeller marked this conversation as resolved.
Outdated
}) => basePage.generateMetadata({ params, prefix: 'blog' });

// Generates all possible static paths based on the locales and environment configuration
// - Returns an empty array if static export is disabled (`ENABLE_STATIC_EXPORT` is false)
Expand Down
14 changes: 10 additions & 4 deletions apps/site/next.dynamic.page.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { join } from 'node:path';
Comment thread
avivkeller marked this conversation as resolved.

import { notFound, redirect } from 'next/navigation';
import { setRequestLocale } from 'next-intl/server';

Expand All @@ -23,15 +25,19 @@ export const generateViewport = () => ({ ...PAGE_VIEWPORT });
*
* @see https://nextjs.org/docs/app/api-reference/functions/generate-metadata
*
* @param {{ params: Promise<{ path: Array<string>; locale: string }> }} props
* @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 = [], locale = defaultLocale.code } = await props.params;
export const generateMetadata = async ({ params, prefix }) => {
const { path = [], locale = defaultLocale.code } = await params;

const pathname = dynamicRouter.getPathname(path);

return dynamicRouter.getPageMetadata(locale, pathname);
return dynamicRouter.getPageMetadata(
locale,
// If there's a prefix, `join` it with the pathname
prefix ? join(prefix, pathname) : pathname
);
};

/**
Expand Down
Loading