Skip to content

Commit

Permalink
Add links pages to sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Sep 29, 2024
1 parent d3e8510 commit 8d993f6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/routes/sitemap[.]xml.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getAll, initialize } from "~/components/Patterns";
import { MIN_ARCHIVE_YEAR } from "~/util/constants";

function urlLine(url:string) {
return `\t<url><loc>https://www.regex.zone${url}</loc></url>`
Expand All @@ -22,6 +23,17 @@ export async function loader() {
lines.push(urlLine(`/patterns/${entry.handle}/`));
}

lines.push(urlLine('/links/'));
lines.push(urlLine('/links/tags.html'));
lines.push(urlLine('/links/archive/'));
const currentYear = new Date().getFullYear();
for (let year = MIN_ARCHIVE_YEAR; year <= currentYear; year++) {
if (year == 2010) {
continue; // hack since no links in 2010
}
lines.push(urlLine(`/links/archive/${year}/`));
}

lines.push('</urlset>')

return new Response(lines.join('\n'), {
Expand Down

0 comments on commit 8d993f6

Please sign in to comment.