diff --git a/.gitignore b/.gitignore index d8fc90b..68d7568 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ app/.pnpm-store app/node_modules app/dist +app/public/sitemap.xml **/*~lock* \ No newline at end of file diff --git a/app/public/sitemap.xml b/app/public/sitemap.xml deleted file mode 100644 index 9295e87..0000000 --- a/app/public/sitemap.xml +++ /dev/null @@ -1 +0,0 @@ -http://localhost:5500/2025-04-18T15:51:43.576Z1.0http://localhost:5500/certifications2025-04-18T15:51:43.576Z0.9http://localhost:5500/docs2025-04-18T15:51:43.576Z0.9http://localhost:5500/docs/communaute/influenceurs2025-04-18T15:51:43.576Z0.7http://localhost:5500/docs/communaute/partages2025-04-18T15:51:43.576Z0.7http://localhost:5500/mentions-legales2025-04-18T15:51:43.576Z0.9http://localhost:5500/politique-de-confidentialite2025-04-18T15:51:43.576Z0.9http://localhost:5500/certifications/dwwm2025-04-18T15:51:43.576Z0.8http://localhost:5500/certifications/dwwm/at12025-04-18T15:51:43.576Z0.7http://localhost:5500/certifications/dwwm/at22025-04-18T15:51:43.576Z0.7http://localhost:5500/docs/react2025-04-18T15:51:43.576Z0.8http://localhost:5500/docs/merise2025-04-18T15:51:43.576Z0.8 \ No newline at end of file diff --git a/app/services/Sitemap.ts b/app/services/Sitemap.ts index ff2a3dc..c7e8918 100644 --- a/app/services/Sitemap.ts +++ b/app/services/Sitemap.ts @@ -79,33 +79,61 @@ class Sitemap { return (1 - countOfSlashes * 0.1).toFixed(1); } - private loadLastModified(href: string): string {} + private loadLastModified(href: string): string { + return this.lastModified; + } - private loadFile(href: string) {} + private getFileServerLocation(href: string) { + const jsxHref = ["/politique-de-confidentialite", "/mentions-legales"]; + const isJsxFile = jsxHref.includes(href); + + if (isJsxFile) { + return path.join(this.pagesPath, href.replace("/", ""), "+Page.tsx"); + } + + return path.join(this.pagesPath, href.replace("/", ""), "page.md"); + } + + private loadSubitems(subitems: (typeof navigation)[number]["links"][number]["subitems"]): void { + subitems.forEach((subitem) => { + const fileLocation = this.getFileServerLocation(subitem.href); + console.log("File location:", fileLocation); + + const priority = this.loadPriority(subitem.href); + const lastmod = this.loadLastModified(subitem.href); + const location = `${this.baseUrl}${subitem.href}`; + + this.urls.push({ + location, + lastmod, + priority, + }); + }); + } + + private loadSection(section: (typeof navigation)[number]): void { + section.links.forEach((link) => { + if (link.subitems.length > 0) { + return this.loadSubitems(link.subitems); + } - private loadSection(sectionLinks: (typeof navigation)[number]["links"]) { - return sectionLinks.map((link) => { const priority = this.loadPriority(link.href); const lastmod = this.loadLastModified(link.href); const location = `${this.baseUrl}${link.href}`; - return { + this.urls.push({ location, lastmod, priority, - }; + }); }); } private loadUrls(): void { - this.urls = navigation.flatMap((section) => { - return Array.from( - new Set( - this.loadSection(section.links) - .filter((url) => url !== null) - .sort((a, b) => a.location.localeCompare(b.location)), - ), - ); + navigation.forEach(this.loadSection.bind(this)); + + this.urls = Array.from(new Set(this.urls)).sort((a, b) => { + return a.location.localeCompare(b.location); }); console.log("Loaded URLs:", this.urls);