Files
vula-f7951bab/src/app/sitemap.ts
T
Vula Builder 2e99c6d2e8 Deploy
2026-10-11 14:20:22 +00:00

32 lines
957 B
TypeScript

import type { MetadataRoute } from 'next'
export const revalidate = 3600
const ROUTES = ["/","/menu"]
async function siteUrl(): Promise<string | null> {
const base = process.env.NEXT_PUBLIC_VULA_COMMERCE_URL
const id = process.env.NEXT_PUBLIC_VULA_PROJECT_ID
if (!base || !id) return null
try {
const res = await fetch(base + '/api/public/profile/' + id, { next: { revalidate: 3600 } })
if (!res.ok) return null
const url = (await res.json())?.profile?.siteUrl
return typeof url === 'string' && url.startsWith('http') ? url.replace(/\/$/, '') : null
} catch {
return null
}
}
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const origin = await siteUrl()
if (!origin) return []
const now = new Date()
return ROUTES.map((path) => ({
url: origin + (path === '/' ? '' : path),
lastModified: now,
changeFrequency: 'weekly' as const,
priority: path === '/' ? 1 : 0.7,
}))
}