Deploy
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
import type { MetadataRoute } from 'next'
|
||||||
|
|
||||||
|
export const revalidate = 3600
|
||||||
|
|
||||||
|
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 robots(): Promise<MetadataRoute.Robots> {
|
||||||
|
const origin = await siteUrl()
|
||||||
|
return {
|
||||||
|
rules: {
|
||||||
|
userAgent: '*',
|
||||||
|
allow: '/',
|
||||||
|
// One customer's booking, a half-filled basket, somebody's account.
|
||||||
|
// None of these belong in a search result.
|
||||||
|
disallow: ['/b/', '/checkout', '/account/', '/api/'],
|
||||||
|
},
|
||||||
|
// Named only when we know the address. Pointing at a sitemap that is not
|
||||||
|
// there is a fault a crawler reports and nobody sees.
|
||||||
|
...(origin ? { sitemap: origin + '/sitemap.xml' } : {}),
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user