-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support generate dynamic sitemaps for dynamic routes (#48867)
### What For dynamic routes you might have different sitemap for different params * Unloack using `sitemap.[ext]` in your app everywhere * Support `generateSitemaps()` to create multiple sitemaps at the same time ### How * Change the metadata regex to allow use sitemap in every routes * Similar approach to `generateImageMetadata`, we make `sitemap.js` under dynamic routes to a catch all routes, and it can have multiple routes Closes NEXT-1054
- Loading branch information
Showing
8 changed files
with
104 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/e2e/app-dir/metadata-dynamic-routes/app/(group)/dynamic/[size]/sitemap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { MetadataRoute } from 'next' | ||
|
||
export async function generateSitemaps() { | ||
return [{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }] | ||
} | ||
|
||
export default function sitemap({ id }): MetadataRoute.Sitemap { | ||
return [ | ||
{ | ||
url: `https://example.com/dynamic/${id}`, | ||
lastModified: '2021-01-01', | ||
}, | ||
{ | ||
url: `https://example.com/dynamic/${id}/about`, | ||
lastModified: '2021-01-01', | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters