feat(web): render cms pages and navigation from db
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import { listPublishedPageSlugs } from "@cms/db"
|
||||
import type { MetadataRoute } from "next"
|
||||
|
||||
const baseUrl = process.env.CMS_WEB_ORIGIN ?? "http://localhost:3000"
|
||||
|
||||
const publicRoutes = ["/", "/about", "/contact"]
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const pages = await listPublishedPageSlugs()
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
const now = new Date()
|
||||
|
||||
return publicRoutes.map((route) => ({
|
||||
url: `${baseUrl}${route}`,
|
||||
lastModified: now,
|
||||
return pages.map((page) => ({
|
||||
url: page.slug === "home" ? `${baseUrl}/` : `${baseUrl}/${page.slug}`,
|
||||
lastModified: page.updatedAt,
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user