UNPKG

metafy-seo

Version:

Lightweight, SSR-safe React components and utilities for managing SEO metadata. Supports Next.js App Router, Vite, and any React environment.

32 lines (31 loc) 1.43 kB
/** * SSR and utility helpers for metafy-seo */ /** Check if code is running on server (no window/document) */ export declare const isServer: boolean; /** Check if code is running on client (has window/document) */ export declare const isClient: boolean; /** * Escape HTML entities to prevent XSS attacks in meta tag content. * * @param str - The string to escape * @returns Escaped string safe for HTML attributes */ export declare function escapeHtml(str: string): string; /** * Helper to upsert a DOM element in <head>. * * @param head - The document.head element. * @param added - Array to track elements created by this component (for cleanup). * @param tag - Tag name ('meta' or 'link'). * @param uniqueKey - The attribute name used to identify the tag (e.g. 'name', 'property', 'rel'). * @param uniqueValue - The value for that attribute (e.g. 'description', 'og:title'). * @param attrs - Full map of attributes to set on the element. * @returns The created/updated element, or null if running on server */ export declare function upsertTag(head: HTMLElement, added: HTMLElement[], tag: 'meta' | 'link', uniqueKey: string, uniqueValue: string, attrs: Record<string, string>): HTMLElement | null; /** * Deep merge two objects, with source values taking precedence. * Useful for merging SEO configs. */ export declare function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>): T;