@ai-growth/nextjs
Version:
Seamlessly integrate Sanity CMS with Next.js applications for automated blog routing and rendering
367 lines • 9.97 kB
TypeScript
/**
* @fileoverview Enhanced SEO Types and Interfaces
*
* This module provides comprehensive type definitions for SEO functionality,
* extending the base Sanity SEO types with additional features for meta tags,
* structured data, and social media integration.
*/
import { SanitySEO, SanityImage, SanityAuthor, SanityPost, SanityPage, SanitySiteSettings } from './sanity';
/**
* Extended SEO metadata with additional social and technical fields
*/
export interface ExtendedSEO extends SanitySEO {
/** Open Graph specific overrides */
openGraph?: OpenGraphData;
/** Twitter Card specific overrides */
twitterCard?: TwitterCardData;
/** JSON-LD structured data */
structuredData?: StructuredData[];
/** Additional meta tags */
additionalMeta?: MetaTag[];
/** Language/locale for the content */
locale?: string;
/** Alternate language versions */
alternateLanguages?: AlternateLanguage[];
/** Publication date for content freshness */
publishedTime?: string;
/** Last modification date */
modifiedTime?: string;
/** Content expiration date */
expirationTime?: string;
/** Article/content author */
author?: string | SanityAuthor;
/** Content section/category */
section?: string;
/** Content tags */
tags?: string[];
/** Estimated reading time */
readingTime?: number;
}
/**
* Open Graph metadata for social media sharing
*/
export interface OpenGraphData {
/** Open Graph type (article, website, product, etc.) */
type?: 'website' | 'article' | 'book' | 'profile' | 'video' | 'music' | 'product';
/** Page title for social sharing */
title?: string;
/** Page description for social sharing */
description?: string;
/** Featured image for social sharing */
image?: SanityImage | string;
/** Image alt text */
imageAlt?: string;
/** Site name */
siteName?: string;
/** Canonical URL */
url?: string;
/** Locale */
locale?: string;
/** Article-specific metadata */
article?: {
author?: string;
publishedTime?: string;
modifiedTime?: string;
expirationTime?: string;
section?: string;
tags?: string[];
};
/** Video-specific metadata */
video?: {
url: string;
type?: string;
width?: number;
height?: number;
duration?: number;
};
}
/**
* Twitter Card metadata
*/
export interface TwitterCardData {
/** Twitter Card type */
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
/** Twitter handle of the site */
site?: string;
/** Twitter handle of the content creator */
creator?: string;
/** Card title */
title?: string;
/** Card description */
description?: string;
/** Card image */
image?: SanityImage | string;
/** Image alt text */
imageAlt?: string;
/** App-specific metadata */
app?: {
name?: string;
id?: {
iphone?: string;
ipad?: string;
googleplay?: string;
};
url?: {
iphone?: string;
ipad?: string;
googleplay?: string;
};
};
/** Player-specific metadata */
player?: {
url: string;
width: number;
height: number;
stream?: string;
};
}
/**
* Individual meta tag definition
*/
export interface MetaTag {
/** Meta tag name attribute */
name?: string;
/** Meta tag property attribute (for Open Graph) */
property?: string;
/** Meta tag content */
content: string;
/** HTTP-equiv attribute */
httpEquiv?: string;
/** Charset attribute */
charset?: string;
}
/**
* Alternate language version definition
*/
export interface AlternateLanguage {
/** Language code (e.g., 'en', 'es', 'fr') */
language: string;
/** Region code (e.g., 'US', 'GB', 'ES') */
region?: string;
/** Full URL to the alternate version */
url: string;
}
/**
* Base interface for JSON-LD structured data
*/
export interface StructuredData {
/** Schema.org type */
'@type': string;
/** Schema.org context */
'@context'?: string;
/** Schema ID */
'@id'?: string;
/** Additional schema properties */
[key: string]: any;
}
/**
* Article structured data
*/
export interface ArticleStructuredData extends StructuredData {
'@type': 'Article' | 'BlogPosting' | 'NewsArticle';
headline: string;
description?: string;
image?: string | string[];
author?: PersonStructuredData | OrganizationStructuredData;
publisher?: OrganizationStructuredData;
datePublished?: string;
dateModified?: string;
mainEntityOfPage?: string;
url?: string;
keywords?: string[];
articleSection?: string;
wordCount?: number;
}
/**
* Person structured data
*/
export interface PersonStructuredData extends StructuredData {
'@type': 'Person';
name: string;
image?: string;
url?: string;
sameAs?: string[];
jobTitle?: string;
worksFor?: OrganizationStructuredData;
}
/**
* Organization structured data
*/
export interface OrganizationStructuredData extends StructuredData {
'@type': 'Organization';
name: string;
url?: string;
logo?: string;
sameAs?: string[];
contactPoint?: ContactPointStructuredData[];
}
/**
* Contact point structured data
*/
export interface ContactPointStructuredData extends StructuredData {
'@type': 'ContactPoint';
telephone?: string;
contactType?: string;
email?: string;
url?: string;
}
/**
* Website structured data
*/
export interface WebsiteStructuredData extends StructuredData {
'@type': 'WebSite';
name: string;
url: string;
description?: string;
publisher?: OrganizationStructuredData;
potentialAction?: SearchActionStructuredData;
}
/**
* Search action structured data
*/
export interface SearchActionStructuredData extends StructuredData {
'@type': 'SearchAction';
target: string;
'query-input': string;
}
/**
* Breadcrumb structured data
*/
export interface BreadcrumbStructuredData extends StructuredData {
'@type': 'BreadcrumbList';
itemListElement: BreadcrumbItemStructuredData[];
}
/**
* Breadcrumb item structured data
*/
export interface BreadcrumbItemStructuredData extends StructuredData {
'@type': 'ListItem';
position: number;
name: string;
item?: string;
}
/**
* Props for the main SEO Head component
*/
export interface SEOHeadProps {
/** Content data (post, page, etc.) */
content?: SanityPost | SanityPage | any;
/** Site settings for defaults */
siteSettings?: SanitySiteSettings;
/** Custom SEO overrides */
seo?: ExtendedSEO;
/** Page template type for specialized handling */
template?: 'home' | 'article' | 'page' | 'category' | 'author' | 'custom';
/** Current page URL */
url?: string;
/** Base URL for the site */
baseUrl?: string;
/** Whether to include default structured data */
includeStructuredData?: boolean;
/** Custom structured data to add */
customStructuredData?: StructuredData[];
/** Additional meta tags */
additionalMeta?: MetaTag[];
/** Whether to include Twitter Card tags */
includeTwitterCard?: boolean;
/** Whether to include Open Graph tags */
includeOpenGraph?: boolean;
/** Default image for social sharing */
defaultImage?: SanityImage | string;
/** Organization data for structured data */
organization?: OrganizationStructuredData;
/** Custom title template */
titleTemplate?: string;
/** Title separator */
titleSeparator?: string;
}
/**
* SEO configuration for the component
*/
export interface SEOConfig {
/** Default site name */
siteName: string;
/** Default title template */
titleTemplate: string;
/** Title separator */
titleSeparator: string;
/** Default description */
defaultDescription: string;
/** Default image */
defaultImage: string;
/** Base URL */
baseUrl: string;
/** Default locale */
locale: string;
/** Twitter site handle */
twitterSite?: string;
/** Organization information */
organization: OrganizationStructuredData;
/** Default Open Graph type */
defaultOGType: OpenGraphData['type'];
/** Default Twitter Card type */
defaultTwitterCard: TwitterCardData['card'];
}
/**
* Result of SEO processing
*/
export interface SEOResult {
/** Generated meta tags */
metaTags: MetaTag[];
/** Generated structured data */
structuredData: StructuredData[];
/** Final title */
title: string;
/** Final description */
description: string;
/** Final canonical URL */
canonical: string;
/** Final image URL */
image?: string;
}
/**
* Content type detection result
*/
export interface ContentTypeResult {
/** Detected content type */
type: 'article' | 'page' | 'author' | 'category' | 'home' | 'unknown';
/** Whether the content is published */
isPublished: boolean;
/** Whether the content should be indexed */
shouldIndex: boolean;
/** Schema.org type to use */
schemaType: string;
/** Open Graph type to use */
ogType: OpenGraphData['type'];
}
/**
* Image processing result for SEO
*/
export interface SEOImageResult {
/** Image URL */
url: string;
/** Image alt text */
alt: string;
/** Image width */
width?: number;
/** Image height */
height?: number;
/** Image type/format */
type?: string;
}
/**
* URL building options
*/
export interface URLBuildOptions {
/** Base URL */
baseUrl: string;
/** Path segments */
path?: string;
/** Query parameters */
query?: Record<string, string>;
/** URL fragment */
fragment?: string;
/** Whether to ensure trailing slash */
trailingSlash?: boolean;
}
//# sourceMappingURL=seo.d.ts.map