Skip to content

Commit 4a17c12

Browse files
committed
Remove error code pages from sitemap
1 parent 735e3c5 commit 4a17c12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/sitemap.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ const PUBLIC_BASE = 'https://luk.ke/';
1010

1111

1212
export const getPaths = () => glob('**/*.html', { cwd: '.next/server/pages', onlyFiles: true })
13+
// Remove .html extensions and remove "index.html" filenames from the ends of paths
1314
.then((paths) => paths.map(((p) => {
14-
// Remove .html extensions and remove "index.html" filenames from the ends of paths
1515
const { dir, name } = path.parse(p);
1616
return `/${name === 'index' ? dir : path.join(dir, name)}`;
1717
})))
18+
// Exclude error code pages (404, 500)
19+
.then((paths) => paths.filter((p) => !/^\/[0-9]{3}$/.test(p)))
1820
.then((paths) => paths.sort());
1921

2022
export async function getSitemap() {

0 commit comments

Comments
 (0)