From 2e99c6d2e8fbb3e05b625ea7cf380e763c83ff6c Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Sun, 11 Oct 2026 14:20:22 +0000 Subject: [PATCH] Deploy --- src/app/sitemap.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 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..ecffcdf --- /dev/null +++ b/src/app/sitemap.ts @@ -0,0 +1,31 @@ +import type { MetadataRoute } from 'next' + +export const revalidate = 3600 + +const ROUTES = ["/","/menu"] + +async function siteUrl(): Promise { + 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 { + 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, + })) +}