-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated with-sitemap example for App Router (#66995)
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>
- Loading branch information
1 parent
fe0368f
commit b5f97ca
Showing
9 changed files
with
80 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const metadata = { | ||
title: "Create Next App", | ||
description: "Generated by Next.js", | ||
icons: { | ||
icon: "/favicon.ico", | ||
}, | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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]; | ||
} |
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 |
---|---|---|
@@ -1,10 +1,2 @@ | ||
/** @type {import('next').NextConfig} */ | ||
module.exports = { | ||
webpack: (config, { isServer }) => { | ||
if (isServer) { | ||
require("./scripts/generate-sitemap"); | ||
} | ||
|
||
return config; | ||
}, | ||
}; | ||
module.exports = {}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
] | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |