b5f97ca70e
Hello This PR updates the with-sitemap example to use: 1. App Router 2. TypeScript 3. sitemap.js --------- Co-authored-by: Sam Ko <sam@vercel.com>
24 lines
580 B
TypeScript
24 lines
580 B
TypeScript
const globby = require("globby");
|
|
|
|
function addPage(page: string) {
|
|
const path = page
|
|
.replace("app", "")
|
|
.replace(".tsx", "")
|
|
.replace(".mdx", "")
|
|
.replace("/page", "");
|
|
return path;
|
|
}
|
|
export default async function sitemap() {
|
|
const pages = await globby([
|
|
"app/**/*{.js,jsx,ts,tsx,.mdx}",
|
|
"!app/_*.js",
|
|
"!app/{sitemap,layout}.{js,jsx,ts,tsx}",
|
|
"!app/api",
|
|
]);
|
|
const routes = pages.map((page: string) => ({
|
|
url: `${process.env.WEBSITE_URL}${addPage(page)}`,
|
|
lastModified: new Date().toISOString(),
|
|
}));
|
|
|
|
return [...routes];
|
|
}
|