UNPKG

astro-loader-hashnode

Version:

Astro content loader for seamlessly integrating Hashnode blog posts into your Astro website using the Content Layer API

114 lines (113 loc) 2.83 kB
/** * Core loader types - replacing any types with proper TypeScript interfaces */ import type { HashnodePost, HashnodeSeries } from './hashnode.js'; export interface LoaderConfig { loader: AstroLoader; } export interface AstroLoader { name: string; load: (context: LoaderContext) => Promise<void>; } export interface LoaderContext { store: DataStore; logger: Logger; parseData: (data: unknown) => Promise<unknown>; } export interface DataStore { set: (entry: DataEntry) => void; get: (id: string) => DataEntry | undefined; has: (id: string) => boolean; clear: () => void; keys: () => string[]; delete: (id: string) => boolean; } export interface DataEntry { id: string; data: { id: string; data: unknown; }; digest: string; } export interface Logger { info: (message: string) => void; warn: (message: string) => void; error: (message: string) => void; } export type AnyLoaderOptions = import('./loader.js').PostsLoaderOptions | import('./loader.js').SeriesLoaderOptions | import('./loader.js').SearchLoaderOptions | import('./loader.js').DraftsLoaderOptions; export interface GraphQLResponse<T = unknown> { data?: T; errors?: Array<{ message: string; locations?: Array<{ line: number; column: number; }>; path?: Array<string | number>; }>; } export interface CacheEntry { data: unknown; timestamp: number; ttl: number; } export interface ProcessedContent { html: string; text: string; excerpt?: string; readingTime?: number; wordCount: number; headings?: Array<{ level: number; text: string; id?: string; }>; tableOfContents?: Array<{ id: string; level: number; title: string; slug: string; parentId?: string; }>; } export interface JSONLDStructuredData { '@context': string; '@type': string; headline?: string; description?: string; author?: { '@type': string; name: string; url?: string; }; publisher?: { '@type': string; name: string; url?: string; logo?: { '@type': string; url: string; }; }; datePublished?: string; dateModified?: string; url?: string; image?: string | { '@type': string; url: string; }; [key: string]: unknown; } export interface SitemapEntry { loc: string; lastmod?: string; changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'; priority?: string; } export type TransformableItem = HashnodePost | HashnodeSeries; export interface SearchResult { post: HashnodePost; searchTerm: string; relevance?: number; }