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) • 970 B
TypeScript
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
* - All content is HTML escaped for security
*
* @example
* ```js
* import { generateSeoMarkup } from 'metafy-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' }
* })
* ```
*
* @param config - The SEO configuration object.
* @returns A string of newline-separated head tags.
*/
export declare function generateSeoMarkup(config: SeoConfig): string;