/**
* Nexus Metadata API — type-safe, XSS-safe `
` metadata for .nx pages.
*
* Usage in a page or layout frontmatter (server block):
*
* ```ts
* export const nxPretext = async (ctx) => {
* return {
* meta: defineMetadata({
* title: ctx.params.name + ' — My App',
* description: 'Profile page for ' + ctx.params.name,
* og: { image: 'https://cdn.example.com/og.png' },
* }),
* };
* };
* ```
*
* In the layout template:
*
* ```html
*
* {{{ pretext.meta?.html ?? '' }}}
*
* ```
*
* All dynamic values are HTML-escaped before injection to prevent XSS via
* user-controlled title / description strings.
*/
export interface MetadataInput {
/** Page title — becomes `` and `og:title`. */
title?: string;
/** Short description — becomes `` and `og:description`. */
description?: string;
/** Canonical URL for this page. */
canonical?: string;
/** Robots directive (default: 'index, follow'). */
robots?: string;
/** Open Graph fields. */
og?: {
title?: string;
description?: string;
image?: string;
type?: string;
url?: string;
siteName?: string;
};
/** Twitter card fields. */
twitter?: {
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
title?: string;
description?: string;
image?: string;
creator?: string;
site?: string;
};
/** Arbitrary additional `` tags. */
extra?: Array<{
name?: string;
property?: string;
content: string;
}>;
}
export interface MetadataResult {
/** Raw HTML string safe for injection into ``. All values are escaped. */
html: string;
/** Original input (for programmatic access). */
input: MetadataInput;
}
/**
* Escapes a string for safe use inside HTML attribute values and text content.
* Prevents XSS when injecting user-controlled strings into `` tags.
*/
export declare function escapeHtml(value: string): string;
/**
* Builds XSS-safe `` metadata from a typed descriptor.
*
* @deprecated Use `defineHead()` from `@nexus_js/head` instead. It now auto-injects
* during SSR when used in `load()` or server blocks. This function is kept for
* backward compatibility but will be removed in a future major release.
*
* @returns `MetadataResult` — inject `.html` into your layout's ``.
*
* @example
* ```ts
* const meta = defineMetadata({
* title: 'My Page',
* description: 'Welcome to my site',
* og: { image: 'https://cdn.example.com/og.png', type: 'website' },
* twitter: { card: 'summary_large_image', creator: '@myhandle' },
* });
* // meta.html → safe HTML string for
* ```
*/
export declare function defineMetadata(input: MetadataInput): MetadataResult;
//# sourceMappingURL=metadata.d.ts.map