Skip to content

Commit

Permalink
fix dynamic routes
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Apr 18, 2023
1 parent 7225b20 commit 4dcc14d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/next/src/lib/metadata/get-metadata-route.ts
Expand Up @@ -32,8 +32,7 @@ export function normalizeMetadataRoute(page: string) {
let route = page
if (isMetadataRoute(page)) {
// Remove the file extension, e.g. /route-path/robots.txt -> /route-path
const { dir, name: baseName, ext } = path.parse(page)
const pathnamePrefix = page.slice(0, -(baseName.length + 1))
const pathnamePrefix = page.slice(0, -(path.basename(page).length + 1))
const suffix = getMetadataRouteSuffix(pathnamePrefix)

if (route === '/sitemap') {
Expand All @@ -48,7 +47,8 @@ export function normalizeMetadataRoute(page: string) {
// Support both /<metadata-route.ext> and custom routes /<metadata-route>/route.ts.
// If it's a metadata file route, we need to append /[id]/route to the page.
if (!route.endsWith('/route')) {
const isStaticMetadataFile = isMetadataRouteFile(page, [], true)
const isStaticMetadataFile = isMetadataRouteFile(route, [], true)
const { dir, name: baseName, ext } = path.parse(route)

const isSingleRoute =
page.startsWith('/sitemap') ||
Expand Down

0 comments on commit 4dcc14d

Please sign in to comment.