UNPKG

react-headless-yoast

Version:

A React component that handles Yoast SEO in a Headless WordPress site.

145 lines (144 loc) 3.99 kB
import React from 'react'; export interface PageSchemaItem { '@type': any; '@id': string; url: string; name: any; isPartOf: { '@id': string; }; description: any; inLanguage: string; potentialAction: { '@type': string; target: string[]; }[]; datePublished?: string; dateModified?: string; } export interface PageSchema { '@context': string; '@graph': PageSchemaItem[]; } export interface SiteSchema { companyName: string; companyLogo?: SeoImage; inLanguage?: string; siteName?: string; siteUrl?: string; } export interface Social { twitter: string; } export interface SeoImage { sourceUrl?: string; altText?: string; srcSet?: string; } export interface SeoOptions { title: string; description: string; locale: string; pageSchema?: PageSchema; siteSchema?: SiteSchema; readingTime?: string; canonical?: string; cornerstone?: string; focusKeyword?: string; keywords?: string; robots: { index: 'noindex' | 'index' | string; follow: 'nofollow' | 'follow' | string; }; og?: { title?: string; description?: string; image?: SeoImage; type: string; url?: string; siteName?: string; publisher?: string; modifiedTime?: string; publishedTime?: string; author?: string; }; twitter?: { title?: string; description?: string; creator?: string; image?: SeoImage; }; } export interface PageSeo { title?: string; locale?: string; seo?: { breadcrumbs?: { text: string; url: string; }; schema?: { articleType: string; pageType: string; raw: string; }; canonical?: string; cornerstone?: string; focuskw?: string; metaDesc?: string; metaKeywords?: string; metaRobotsNofollow?: string; metaRobotsNoindex?: string; opengraphAuthor?: string; opengraphDescription?: string; opengraphImage?: SeoImage; opengraphModifiedTime?: string; opengraphPublishedTime?: string; opengraphPublisher?: string; opengraphSiteName?: string; opengraphTitle?: string; opengraphType?: string; opengraphUrl?: string; readingTime?: string; title?: string; twitterDescription?: string; twitterImage?: SeoImage; twitterTitle?: string; }; author?: { node?: { seo?: { metaDesc?: string; metaRobotsNofollow?: string; metaRobotsNoindex?: string; schema?: { raw: string; }; social?: { facebook?: string; twitter?: string; }; title?: string; }; }; }; } export declare function toTwitter(str?: string): string | undefined; export declare function postToSeoOptions(page: PageSeo, pageSchema?: PageSchema | string, siteSchema?: SiteSchema | string): SeoOptions; export interface SeoProps { meta?: React.ReactFragment; page?: PageSeo; pageSchema?: PageSchema; siteSchema?: SiteSchema; processSchema?: (schema: string) => string; /** * This must be a React component that will render meta tags into the <head> element in the HTML * * @type {React.ComponentType<{ children: React.ReactNode }>} * @memberof SeoProps */ MetaRenderElement: React.ComponentType<{ children: React.ReactNode; }>; } export default function Seo({ meta, page, pageSchema, siteSchema, MetaRenderElement, processSchema, }: SeoProps): JSX.Element;