UNPKG

metafetch

Version:

Metafetch fetches a given URL's title, description, images, links etc.

61 lines (60 loc) 1.48 kB
export interface MetafetchResponse { title?: string; description?: string; type?: string; url?: string; originalURL?: string; ampURL?: string; siteName?: string; charset?: string; image?: string; meta?: Record<string, string>; images?: string[]; links?: string[]; headers?: Record<string, string>; language?: string; favicon?: string; feeds?: string[]; } type FlagOptions = { title?: boolean; description?: boolean; type?: boolean; url?: boolean; siteName?: boolean; charset?: boolean; image?: boolean; meta?: boolean; images?: boolean; links?: boolean; headers?: boolean; language?: boolean; favicon?: boolean; feeds?: boolean; }; export interface FetchOptions { userAgent?: string; fetch?: RequestInit; flags?: FlagOptions; render?: boolean; retries?: number; retryDelay?: number; } export declare class Metafetch { #private; constructor(ua?: string); setUserAgent(agent: string): void; get userAgent(): string; private _getPuppeteer; fetch(url: string, options?: FetchOptions): Promise<MetafetchResponse>; private _detectCharset; private _extractMeta; private _extractUrls; private _extractAssets; private _flattenJsonLd; private _extractStructuredData; private _extractFavicon; private _extractFeeds; } export declare const metafetch: Metafetch; export default metafetch;