ogp.ts
11 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference
fncollectOgpUrls(html: string): Promise<string[]>Collect all OGP URLs from HTML for pre-fetching.
fncreateFallbackCard(url: string): ElementCreate fallback element when OGP data is unavailable.
Create fallback element when OGP data is unavailable.
Parameters
-
urlstring
Returns
Element
fncreateOgpCard(data: OgpData): ElementCreate OGP card element.
fnextractDomain(url: string): stringExtract domain from URL.
fnfetchOgpData(url: string, options: Required<OgpOptions>): Promise<OgpData | null>Fetch OGP data for a URL.
fngetAttribute(el: Element, name: string): string | undefinedGet element attribute value.
Get element attribute value.
Parameters
-
elElement -
namestring
Returns
string | undefined
fngetFaviconUrl(url: string): stringGet favicon URL for a domain.
fnparseOgpFromHtml(html: string, url: string): OgpDataParse OGP metadata from HTML.
fnprefetchOgpData(urls: string[], options?: OgpOptions): Promise<Map<string, OgpData | null>>Pre-fetch all OGP data.
Pre-fetch all OGP data.
Parameters
-
urlsstring[] -
optionsOgpOptionsoptional
Returns
Promise
fnrehypeOgp(ogpDataMap: Map<string, OgpData | null>)Rehype plugin to transform OgCard components.
fntransformOgp(html: string, ogpDataMap?: Map<string, OgpData | null>, options?: OgpOptions): Promise<string>Transform OgCard components in HTML.
Transform OgCard components in HTML.
Parameters
-
htmlstring -
ogpDataMapMapoptional
-
optionsOgpOptionsoptional
Returns
Promise