UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

31 lines (30 loc) 1.53 kB
import type { AnyCaller } from "../../util/function.js"; import type { AbsolutePath } from "../../util/path.js"; import { type URIParams } from "../../util/uri.js"; import { type ImmutableURL } from "../../util/url.js"; import { type Meta, type PossibleMeta } from "../util/meta.js"; /** Context to store the `Config` object. */ export declare const MetaContext: import("react").Context<Meta>; /** * Use the current meta context in a component. * * @param meta A set of new possible meta data to combine into the current meta context. */ export declare function requireMeta(meta?: PossibleMeta): Meta; /** A `Meta` object with a defined `url` object, and `path` and `params` properties combined in. */ export interface MetaURL extends Meta { url: ImmutableURL; /** The path of `url` relative to `meta.root` (i.e. the _site-root-relative_ path). */ path: AbsolutePath; /** The `?query` params of `url` extracted as a flat set of parameters. */ params: URIParams; } /** * Use the current meta context in a component with some additional URL helpers. * * @param meta A set of new possible meta data to combine into the current meta context. * @returns A `Meta` object with a defined `url` object, and `path` and `params` properties combined in. * @throws {RequiredError} if the current meta has no `url` * @throws {RequiredError} if the current meta `url` does not match the origin of the current meta `root` */ export declare function requireMetaURL(meta?: PossibleMeta, caller?: AnyCaller): MetaURL;