import type { MetadataRoute } from 'next' const siteUrl = process.env.NEXT_PUBLIC_SITE_URL // In production, warn loudly but don't crash — the sitemap will use the // fallback URL. Set NEXT_PUBLIC_SITE_URL in your deployment env to get the // correct absolute URLs in sitemap.xml. if (!siteUrl && process.env.NODE_ENV === 'production') { console.warn( '[sitemap] NEXT_PUBLIC_SITE_URL is not set — sitemap will use https://trumpsignal.com as fallback. ' + 'Set this env var in your deployment to avoid incorrect sitemap URLs.', ) } const base = (siteUrl || 'https://trumpsignal.com').replace(/\/$/, '') const routes: Array<{ path: string priority: number freq: MetadataRoute.Sitemap[number]['changeFrequency'] }> = [ { path: '', priority: 1.0, freq: 'hourly' }, { path: '/trump', priority: 0.9, freq: 'hourly' }, { path: '/macro', priority: 0.9, freq: 'daily' }, { path: '/kol', priority: 0.9, freq: 'daily' }, { path: '/trades', priority: 0.8, freq: 'daily' }, { path: '/analytics', priority: 0.7, freq: 'daily' }, { path: '/methodology', priority: 0.8, freq: 'monthly' }, { path: '/glossary', priority: 0.8, freq: 'monthly' }, { path: '/case-studies', priority: 0.8, freq: 'monthly' }, { path: '/settings', priority: 0.5, freq: 'monthly' }, { path: '/privacy', priority: 0.3, freq: 'yearly' }, { path: '/terms', priority: 0.3, freq: 'yearly' }, { path: '/contact', priority: 0.4, freq: 'monthly' }, ] // i18n shelved — only emit English routes. Add 'zh' back when content is // actually translated (otherwise Google flags duplicate content under hreflang). const locales = ['en'] export default function sitemap(): MetadataRoute.Sitemap { const now = new Date() const entries: MetadataRoute.Sitemap = [] // Root landing (not locale-scoped) entries.push({ url: base, lastModified: now, changeFrequency: 'hourly', priority: 1.0, }) for (const locale of locales) { for (const r of routes) { entries.push({ url: `${base}/${locale}${r.path}`, lastModified: now, changeFrequency: r.freq, priority: r.priority, }) } } return entries }