/** * Pure, fs-free SEO primitives shared by every content module's own SEO builders (`blog/seo.ts`, * `docs/seo.ts`): absolute-URL resolution, the `og:locale` territory map, the hreflang/`x-default` * alternates builder, and the i18n sitemap builder. No `next` or `react` import - the returned * sitemap is a structural {@link SitemapEntry}[] assignable to `MetadataRoute.Sitemap`, and * JSON-LD is returned by the per-module builders as plain objects. * * URLs are built exclusively via {@link localePath} from `./locales.js`, the same helper the * React components use, so the canonical/hreflang metadata can never drift from the rendered * links. */ import type { LocaleConfig, LocalizedText, SiteConfig, SitemapEntry } from "./types.js"; /** A schema.org JSON-LD document (a plain, JSON-serialisable object graph). */ export type JsonLd = Record; /** Fallback locale used only when neither `site.defaultLocale` nor a page language is known. */ export declare const FALLBACK_LOCALE = "en"; /** * The dimensions every hero image is rendered at (`BlogPage`, `BlogOverviewGrid` and `DocsPage` * all hard-code `width={1200} height={630}`), so the same pair is declared on the share card as * `og:image:width`/`og:image:height`. */ export declare const HERO_IMAGE_SIZE: { readonly width: 1200; readonly height: 630; }; /** * Resolves a {@link LocalizedText} for one language: a plain string is the same copy everywhere, a * map is looked up by locale code (case-insensitively, so a lowercased URL segment finds a * `pt-BR` key) and falls back to the site's default locale. * * Returns `undefined` when nothing is configured or the map covers neither language, leaving each * caller to apply its own generic fallback. Never returns another locale's copy: showing Dutch to * a French reader is a worse failure than showing the generic brand string. * * @param text - the configured copy, if any. * @param lang - the language being built. * @param defaultLocale - the site's default locale, used when the map has no entry for `lang`. * @returns the copy for that language, or `undefined`. */ export declare function localizedText(text: LocalizedText | undefined, lang: string | undefined, defaultLocale: string | undefined): string | undefined; /** * The first breadcrumb's name in `lang` ({@link SiteConfig.homeLabel}), `"Home"` when none is set. * * @param site - the site configuration. * @param lang - the locale code. * @returns the localized home label. */ export declare function homeLabel(site: SiteConfig, lang: string): string; /** * Resolves a root-relative path (or absolute URL) to an absolute URL against the site origin. * * A `siteUrl` may carry a sub-path (`https://user.github.io/repo`, the origin of a GitHub Pages * *project* site). That sub-path is **prepended** to a root-relative path rather than discarded - * plain `new URL("/x", "https://h/repo")` would yield `https://h/x`, silently dropping `/repo` * from every sitemap and JSON-LD URL while the canonical, resolved by Next against * `metadataBase`, kept it. This mirrors Next's own `metadataBase` join so the two can never * disagree. * * @param siteUrl - the absolute site origin (`SiteConfig.siteUrl`), optionally with a sub-path. * @param pathOrUrl - a root-relative path (e.g. `/docs/x`) or an already-absolute URL. * @returns the absolute URL string. */ export declare function absoluteUrl(siteUrl: string, pathOrUrl: string): string; /** * The origin a locale's pages are served from: its {@link SiteConfig.localeOrigins} entry on a * domain-per-locale site, else the single `siteUrl`. * * @param site - the site configuration. * @param lang - the locale code. * @returns the absolute origin (possibly with a sub-path, see {@link absoluteUrl}). */ export declare function localeOrigin(site: SiteConfig, lang: string): string; /** * The absolute URL of a public file (a post's hero image) shown on a `lang` page. Public files are * served from the host root plus `siteUrl`'s own sub-path (a GitHub Pages project site's `/repo`), * never under a locale's page mount: an i18nkit locale mounted at `https://example.nl/en` serves * its pages under `/en` but its images at `https://example.nl/assets/...`, so resolving an image * against the locale origin (`/en/assets/...`) would 404. * * @param site - the site configuration. * @param lang - the page's locale code. * @param pathOrUrl - a root-relative public path (e.g. `/assets/x.jpg`) or an absolute URL. * @returns the absolute URL string. */ export declare function assetUrl(site: SiteConfig, lang: string, pathOrUrl: string): string; /** * The base public files resolve against on a `lang` page: the locale's host plus `siteUrl`'s own * sub-path, never the locale's page mount (see {@link assetUrl}). It is the page's `metadataBase`, * so a relative image the host app merges in (a default `og:image`) lands where the file is served; * canonical and hreflang URLs are absolute on a domain-per-locale site, so they are unaffected. * * @param site - the site configuration. * @param lang - the page's locale code. * @returns the absolute base URL string. */ export declare function assetBase(site: SiteConfig, lang: string): string; /** * The root-relative path of a page (or, without `slug`, of a locale's index) under the site's URL * options - {@link localePath} fed from one {@link SiteConfig}, so every builder threads the same * `basePath` / `prefixDefaultLocale` / `localeOrigins` / `trailingSlash`. * * @param site - the site configuration. * @param defaultLocale - the locale served unprefixed (the caller's resolved default). * @param lang - the target locale code. * @param slug - the page slug; omit for the locale's index. * @returns the root-relative path. */ export declare function sitePath(site: SiteConfig, defaultLocale: string, lang: string, slug?: string): string; /** * The absolute URL of a page (or a locale's index) on its locale's origin. * * @param site - the site configuration. * @param defaultLocale - the locale served unprefixed. * @param lang - the target locale code. * @param slug - the page slug; omit for the locale's index. * @returns the absolute URL. */ export declare function pageUrl(site: SiteConfig, defaultLocale: string, lang: string, slug?: string): string; /** * The URL a page's metadata (canonical, hreflang, `og:url`) names: root-relative on a single-origin * site (resolved by Next against `metadataBase`, exactly as before), absolute on a domain-per-locale * site - an hreflang alternate on another domain cannot be root-relative. * * @param site - the site configuration. * @param defaultLocale - the locale served unprefixed. * @param lang - the target locale code. * @param slug - the page slug; omit for the locale's index. * @returns the root-relative path or absolute URL. */ export declare function metadataUrl(site: SiteConfig, defaultLocale: string, lang: string, slug?: string): string; /** * Maps a language subtag to the territory-qualified locale Open Graph expects (`fr` -> `fr_FR`, * `en` -> `en_US`), deriving the territory from the platform's CLDR likely-subtags data via * `Intl.Locale`. A tag that already carries a region is preserved (`pt-BR` -> `pt_BR`); a tag * with no known territory, or a structurally invalid one, falls back to the bare code unchanged. * * @param lang - the language code (from a page's `lang` or a locale's `code`). * @returns the `language_TERRITORY` string for `og:locale`, or the bare `lang` when no territory * can be derived. */ export declare function ogLocale(lang: string): string; /** * A page `` through the site's {@link SiteConfig.titleTemplate} (default `"%s | <brandName>"`). * * @param site - the site configuration. * @param title - the page's own title. * @returns the full title, to be emitted as Next's `title.absolute`. */ export declare function pageTitle(site: SiteConfig, title: string): string; /** * The index page's `<title>` for one language: {@link SiteConfig.indexTitle} (else `fallback`) * through {@link pageTitle}. * * @param site - the site configuration. * @param lang - the language being built. * @param fallback - the section's default index title (`"Blog"` / `"Docs"`). * @returns the full index title. */ export declare function indexPageTitle(site: SiteConfig, lang: string, fallback: string): string; /** * The schema.org `inLanguage` value for one of a site's configured locales: that locale's own BCP 47 * tag ({@link LocaleConfig.dateLocale}, e.g. `en-GB`) when it declares one, else the bare code. * * @param locales - the configured locales (`SiteConfig.locales`), or `undefined`. * @param lang - the language code of the page being built. * @returns the BCP 47 language tag. */ export declare function languageTag(locales: LocaleConfig[] | undefined, lang: string): string; /** * The `og:locale` tag for one of a site's configured locales: {@link ogLocale} applied to that * locale's own BCP 47 tag ({@link LocaleConfig.dateLocale}) when it declares one, else to the bare * code. * * The distinction is the whole point. `ogLocale` maximizes a bare subtag through CLDR, so `en` * becomes `en_US` - which is wrong, and silently so, for a site whose locale set says `en-GB`. The * config already carries the answer; this is the chokepoint that reads it instead of guessing. * * @param locales - the configured locales (`SiteConfig.locales`), or `undefined` when a caller uses * the pure builders without one - every locale then falls back to the bare code as before. * @param lang - the language code of the page being built. * @returns the `language_TERRITORY` string for `og:locale`. */ export declare function ogLocaleFor(locales: LocaleConfig[] | undefined, lang: string): string; /** * Builds an hreflang `hreflang -> url` map from a page's translations, including an `x-default` * entry pointing at the default locale (or the first translation when the default is not among * them). Returns `undefined` when the page has one or no translation, so single-language pages * emit no hreflang tags. The single place the hreflang/`x-default` rules live, shared by the page * metadata, the index metadata, and the sitemap. * * @param translations - the language codes the page is available in, default-locale first. * @param defaultLocale - the locale served as the `x-default` target. * @param urlFor - maps a language code to that translation's URL (root-relative or absolute). * @returns a `hreflang -> url` map (including `x-default`), or `undefined` when not translated. */ export declare function hreflangMap(translations: string[], defaultLocale: string, urlFor: (lang: string) => string): Record<string, string> | undefined; /** * Builds i18n sitemap entries: one per `(slug, lang)` page, each with its absolute URL and - * when the slug is translated - the full hreflang `alternates.languages` map (every translation * plus `x-default`, as absolute URLs). Feed the result straight to a Next.js `sitemap.ts` for an * i18n-correct sitemap. Untranslated pages get a bare `{ url }` with no `alternates`. * * @param refs - every `(slug, lang)` pair to emit (typically `Blog.getPostRefs()` / `Docs.getDocRefs()`). * @param site - the site configuration; `siteUrl` (or each locale's `localeOrigins` entry) makes the * URLs absolute. * @param translationsOf - maps a slug to the language codes it exists in, default-locale first * (typically `Blog.getTranslations` / `Docs.getTranslations`). * @param slugOf - maps a ref's `slug` and a language to that language's URL slug, for pages whose * slug differs per language (the refs' `slug` is then the translation key). Optional; defaults to * the ref's `slug` for every language. * @returns one {@link SitemapEntry} per ref, in the order given. */ export declare function buildSitemap(refs: { slug: string; lang: string; }[], site: SiteConfig, translationsOf: (slug: string) => string[], slugOf?: (slug: string, lang: string) => string): SitemapEntry[];