Skip to main content

Extract social share images and Open Graph tags

Bun’s HTMLRewriter API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
extract-social-meta.ts
Example Usage