Skip to content

Commit

Permalink
Remove error code pages from sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
controversial committed May 13, 2021
1 parent 735e3c5 commit 4a17c12
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/sitemap.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const PUBLIC_BASE = 'https://luk.ke/';


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

export async function getSitemap() {
Expand Down

0 comments on commit 4a17c12

Please sign in to comment.