UNPKG

link-preview-js

Version:

Javascript module to extract and fetch HTTP link information from blocks of text.

33 lines (32 loc) 1.19 kB
import { type ILinkPreviewBaseOptions } from "./shared"; export type { ILinkPreviewResponse, IVideoType, IPreFetchedResource } from "./shared"; export { getPreviewFromContent } from "./shared"; export interface ILinkPreviewOptions extends ILinkPreviewBaseOptions { resolveDNSHost?: (url: string) => Promise<string>; } /** * Parses the text, extracts the first link it finds and does a HTTP request * to fetch the website content, afterwards it tries to parse the internal HTML * and extract the information via meta tags * @param text string, text to be parsed * @param options ILinkPreviewOptions */ export declare function getLinkPreview(text: string, options?: ILinkPreviewOptions): Promise<import("./shared").ILinkPreviewResponse | { url: string; mediaType: string; contentType: string; favicons: string[]; charset: string | null; } | { url: string; title: string; siteName: string | undefined; author: string | undefined; description: string | undefined; mediaType: string; contentType: string | undefined; images: string[]; videos: import("./shared").IVideoType[]; favicons: string[]; charset: string | null; }>;