ogp.ts

Source

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.

Collect all OGP URLs from HTML for pre-fetching.

View source

Parameters

  • html string

Returns

Promise
fncreateFallbackCard(url: string): ElementCreate fallback element when OGP data is unavailable.

Create fallback element when OGP data is unavailable.

View source

Parameters

  • url string

Returns

Element
fncreateOgpCard(data: OgpData): ElementCreate OGP card element.

Create OGP card element.

View source

Parameters

  • data OgpData

Returns

Element
fnextractDomain(url: string): stringExtract domain from URL.

Extract domain from URL.

View source

Parameters

  • url string

Returns

string
fnfetchOgpData(url: string, options: Required<OgpOptions>): Promise<OgpData | null>Fetch OGP data for a URL.

Fetch OGP data for a URL.

View source

Parameters

  • url string
  • options Required

Returns

Promise
fngetAttribute(el: Element, name: string): string | undefinedGet element attribute value.

Get element attribute value.

View source

Parameters

  • el Element
  • name string

Returns

string | undefined
fngetFaviconUrl(url: string): stringGet favicon URL for a domain.

Get favicon URL for a domain.

View source

Parameters

  • url string

Returns

string
fnparseOgpFromHtml(html: string, url: string): OgpDataParse OGP metadata from HTML.

Parse OGP metadata from HTML.

View source

Parameters

  • html string
  • url string

Returns

OgpData
fnprefetchOgpData(urls: string[], options?: OgpOptions): Promise<Map<string, OgpData | null>>Pre-fetch all OGP data.

Pre-fetch all OGP data.

View source

Parameters

  • urls string[]
  • options OgpOptions

    optional

Returns

Promise
fnrehypeOgp(ogpDataMap: Map<string, OgpData | null>)Rehype plugin to transform OgCard components.

Rehype plugin to transform OgCard components.

View source

Parameters

  • ogpDataMap Map
fntransformOgp(html: string, ogpDataMap?: Map<string, OgpData | null>, options?: OgpOptions): Promise<string>Transform OgCard components in HTML.

Transform OgCard components in HTML.

View source

Parameters

  • html string
  • ogpDataMap Map

    optional

  • options OgpOptions

    optional

Returns

Promise