UNPKG

metafy-seo

Version:

Lightweight, dependency-free React components and utilities for managing SEO metadata (meta tags, Open Graph, Twitter Cards) with optional SSR markup generation.

34 lines (33 loc) 1.01 kB
import type { SeoConfig } from './types'; /** * Generate a string of `<title>`, `<meta>`, and `<link>` tags * based on the provided SEO configuration. * * This utility is framework-agnostic and ideal for server-side * rendering or static HTML injection. * * @remarks * - Core tags (title, description, canonical, etc.) * - Open Graph tags (`og:*`) * - Twitter Card tags (`twitter:*`) * - Extra `<meta>` and `<link>` entries * * @example * ```js * import { generateSeoMarkup } from 'react-seo' * * const head = generateSeoMarkup({ * title: 'My SSR Page', * description: 'Hello from the server!', * openGraph: { url: '/page', title: 'OG Title' }, * twitter: { card: 'summary', title: 'Twitter Title' } * }) * * // head: * // "<title>My SSR Page</title>\n<meta name="description" ...>\n..." * ``` * * @param config - The SEO configuration object. * @returns A string of newline-separated head tags. */ export declare function generateSeoMarkup(config: SeoConfig): string;