mirror of
https://github.com/absmach/supermq.git
synced 2026-08-07 10:14:40 +00:00
format sitemap.ts file
Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>
This commit is contained in:
+23
-23
@@ -8,34 +8,34 @@ const DOMAIN = process.env.NEXT_PUBLIC_SITE_URL || "https://fluxmq.absmach.eu";
|
||||
export const dynamic = "force-static";
|
||||
|
||||
function collectPages(dir: string, route = ""): MetadataRoute.Sitemap {
|
||||
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.name.startsWith("[")) return [];
|
||||
return collectPages(fullPath, `${route}/${entry.name}`);
|
||||
}
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.name.startsWith("[")) return [];
|
||||
return collectPages(fullPath, `${route}/${entry.name}`);
|
||||
}
|
||||
|
||||
if (entry.name !== "page.tsx") return [];
|
||||
if (entry.name !== "page.tsx") return [];
|
||||
|
||||
return [
|
||||
{
|
||||
url: DOMAIN + (route || "/"),
|
||||
lastModified: fs.statSync(fullPath).mtime,
|
||||
},
|
||||
];
|
||||
});
|
||||
return [
|
||||
{
|
||||
url: DOMAIN + (route || "/"),
|
||||
lastModified: fs.statSync(fullPath).mtime,
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
const pages = collectPages(path.join(process.cwd(), "app"));
|
||||
const pages = collectPages(path.join(process.cwd(), "app"));
|
||||
|
||||
for (const page of source.getPages()) {
|
||||
pages.push({
|
||||
url: `${DOMAIN}${page.url}`,
|
||||
lastModified: new Date(),
|
||||
});
|
||||
}
|
||||
for (const page of source.getPages()) {
|
||||
pages.push({
|
||||
url: `${DOMAIN}${page.url}`,
|
||||
lastModified: new Date(),
|
||||
});
|
||||
}
|
||||
|
||||
return pages;
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user