/**
* Types for the route metadata a page or layout declares with `export const meta`.
*
* The generated route entry merges every `meta` on the path — root layout to
* page, most specific wins — and renders the result as `
`, ``, and
* `` elements that React 19 hoists into ``. See `routeMetaPrelude()`
* in `packages/ruvyxa/runtime/entry-templates.mjs` for the emitter and
* `META_PRELUDE` in `crates/ruvyxa_bundler/src/output.rs` for its Rust mirror.
*
* ```tsx
* // app/layout.tsx
* export const meta: Meta = {
* titleTemplate: '%s — Ruvyxa',
* siteName: 'Ruvyxa',
* description: 'The React framework with a native heart.',
* }
*
* // app/blog/[slug]/page.tsx — receives the layout's template
* export const meta: MetaFactory = ({ params }) => ({
* title: params.slug,
* canonical: `https://ruvyxa.dev/blog/${params.slug}`,
* })
* ```
*
* `` remains available for per-render metadata inside a component. Do not
* set the same field in both: React hoists both `` elements and the last
* one wins, which is rarely what the author meant.
*/
/** One `` entry. */
export interface MetaAlternate {
/** BCP 47 tag, or `x-default`. */
hreflang: string
/** Absolute URL of the alternate document. */
href: string
}
/** Render context passed to a `meta` function. */
export interface MetaContext {
/** Concrete request path, e.g. `/blog/hello`. */
path: string
/** Dynamic segment values for this request. */
params: Record
}
export interface Meta {
/** Document title. Formatted by the nearest ancestor `titleTemplate`. */
title?: string
/**
* Format applied to titles declared *below* this level; `%s` is the child
* title. A level's own `title` is never formatted by its own template.
*/
titleTemplate?: string
/** Meta description. Required for a perfect Lighthouse SEO score. */
description?: string
/** Absolute canonical URL for this document. */
canonical?: string
/** Written verbatim into ``. Overrides `noindex`. */
robots?: string
/** Shorthand for `robots: 'noindex, nofollow'`. */
noindex?: boolean
/**
* Document language, written onto the `` attribute of the rendered
* document. Client-side navigation does not update it; a locale-segmented
* route tree gets the correct value on every server-rendered document.
*/
lang?: string
/** `` entries for other locales of this page. */
alternates?: readonly MetaAlternate[]
/** Preview image URL used by X and Open Graph consumers. */
image?: string
/** Alternative text for `image`. */
imageAlt?: string
/** `og:site_name`. */
siteName?: string
/** `og:type`. @default "website" */
type?: 'website' | 'article' | 'profile'
/** `og:locale`, e.g. `th_TH`. */
locale?: string
/**
* Shape of the link preview card on X.
*
* Emitted as ``: that is the attribute name X's
* crawler still reads, so the tag keeps the platform's former name even
* though the option does not. Defaults to `summary_large_image` when an image
* is set.
*/
card?: 'summary' | 'summary_large_image'
}
/** A `meta` export declared as a function of the current request. */
export type MetaFactory = (context: MetaContext) => Meta
/** Either shape accepted by `export const meta`. */
export type MetaExport = Meta | MetaFactory