ogp.ts

Source

12 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

12 symbols 11 functions 1 modules 17 parameters 10 returns

Reference

fncollectOgpUrls(html: string): Promise<string[]>Collect all OGP URLs from HTML for pre-fetching.

Collect all OGP URLs from HTML for pre-fetching.

Signature

export async function collectOgpUrls(html: string): Promise<string[]>

View source

Parameters

  • html string

Returns

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

Create fallback element when OGP data is unavailable.

Signature

function createFallbackCard(url: string): Element

View source

Parameters

  • url string

Returns

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

Create OGP card element.

Signature

function createOgpCard(data: OgpData): Element

View source

Parameters

  • data OgpData

Returns

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

Extract domain from URL.

Signature

function extractDomain(url: string): string

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.

Signature

export async function fetchOgpData(url: string, options: Required<OgpOptions>): Promise<OgpData | null>

View source

Parameters

  • url string
  • options Required<OgpOptions>

Returns

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

Get element attribute value.

Signature

function getAttribute(el: Element, name: string): string | undefined

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.

Signature

function getFaviconUrl(url: string): string

View source

Parameters

  • url string

Returns

string
moduleogpOGP Card Plugin - Link card embedding Transforms <OgCard> components into static link preview cards by fetching OGP met…

OGP Card Plugin - Link card embedding

Transforms <OgCard> components into static link preview cards by fetching OGP metadata at build time.

View source

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

Parse OGP metadata from HTML.

Signature

function parseOgpFromHtml(html: string, url: string): OgpData

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.

Signature

export async function prefetchOgpData(urls: string[], options?: OgpOptions): Promise<Map<string, OgpData | null>>

View source

Parameters

  • urls string[]
  • options OgpOptions

    optional

Returns

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

Rehype plugin to transform OgCard components.

Signature

function rehypeOgp(ogpDataMap: Map<string, OgpData | null>)

View source

Parameters

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

Transform OgCard components in HTML.

Signature

export async function transformOgp(html: string, ogpDataMap?: Map<string, OgpData | null>, options?: OgpOptions): Promise<string>

View source

Parameters

  • html string
  • ogpDataMap Map<string, OgpData | null>

    optional

  • options OgpOptions

    optional

Returns

Promise<string>