chore: clean up scratch files and apply remaining updates
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
export const SITE_URL = 'https://marmarislocal.com'
|
||||
export const LOCALES = ['tr', 'en', 'ru'] as const
|
||||
|
||||
/**
|
||||
* Builds self-referencing canonical + reciprocal hreflang alternates for a given
|
||||
* request pathname (as set by proxy.ts on `x-pathname`, e.g. "/en/restoran/foo").
|
||||
* x-default falls back to the site's default locale (tr).
|
||||
*/
|
||||
export function buildAlternates(pathname: string): Metadata['alternates'] {
|
||||
const segments = pathname.split('/').filter(Boolean)
|
||||
const currentLocale = LOCALES.includes(segments[0] as any) ? segments[0] : 'tr'
|
||||
const rest = segments.slice(LOCALES.includes(segments[0] as any) ? 1 : 0).join('/')
|
||||
const suffix = rest ? `/${rest}` : ''
|
||||
|
||||
const languages: Record<string, string> = {}
|
||||
for (const locale of LOCALES) {
|
||||
languages[locale] = `${SITE_URL}/${locale}${suffix}`
|
||||
}
|
||||
languages['x-default'] = `${SITE_URL}/tr${suffix}`
|
||||
|
||||
return {
|
||||
canonical: `${SITE_URL}/${currentLocale}${suffix}`,
|
||||
languages,
|
||||
}
|
||||
}
|
||||
|
||||
export function ogLocale(locale: string): string {
|
||||
return locale === 'en' ? 'en_US' : locale === 'ru' ? 'ru_RU' : 'tr_TR'
|
||||
}
|
||||
|
||||
/**
|
||||
* Metadata for pages that only need a localized title/description, but still
|
||||
* want their own Open Graph/Twitter tags instead of inheriting the layout's
|
||||
* generic sitewide fallback (which would otherwise show on every such page).
|
||||
*/
|
||||
export function basicMetadata(title: string, description: string): Metadata {
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
openGraph: { title, description, type: 'website' },
|
||||
twitter: { card: 'summary_large_image', title, description },
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user