From 64d09691cec7a4e4d55b9e07ba13147088ce27ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Ter=C3=A7ariol=20Rangel?= Date: Wed, 20 Sep 2023 17:39:52 -0300 Subject: [PATCH] Add sitemap (#10) --- src/app/sitemap.ts | 11 +++++++++++ src/services/checklist.ts | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 src/app/sitemap.ts diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts new file mode 100644 index 0000000..44c0788 --- /dev/null +++ b/src/app/sitemap.ts @@ -0,0 +1,11 @@ +import { MetadataRoute } from "next"; +import { ChecklistService } from "@/services/checklist"; + +export default function sitemap(): MetadataRoute.Sitemap { + const checklistPaths = ChecklistService.getInstance().getChecklistFiles(); + + return checklistPaths.map(({ slug, lang, lastModified }) => ({ + url: `https://devchecklists.com/${lang}/checklist/${slug}`, + lastModified, + })); +} diff --git a/src/services/checklist.ts b/src/services/checklist.ts index d5ec93f..1ed6a0b 100644 --- a/src/services/checklist.ts +++ b/src/services/checklist.ts @@ -38,6 +38,7 @@ interface ChecklistFile { slug: string; path: string; lang: string; + lastModified: Date; } export interface Checklist { @@ -273,6 +274,7 @@ export class ChecklistService { files.push({ slug: checklistFolder, path: checklistFilePath, + lastModified: checklistFileStat.mtime, lang: "en", }); continue; @@ -291,6 +293,7 @@ export class ChecklistService { files.push({ slug: checklistFolder, path: checklistFilePath, + lastModified: checklistFileStat.mtime, lang, }); }