Skip to main content

Replied to a post on github.com :

Since I wrote the URL unfurling in Known, I thought I'd go in to a little more detail on how it works:

* When a post is displayed, a bit of javascript looks in the content for the first URL.
* This URL is passed to an endpoint, where
* If it's already been seen the unfurled content is returned
* Otherwise the page is retrieved
* If no error, we extract open graph, twitter, facebook meta tags, OEmbed endpoints, MF2 tags and basic title and description
* This is then saved.

Rendering, this content is used and a card is generated using the following:

* If OEmbed is present and is whitelisted we use that (you don't want to allow oembed for everything, and also OEmbed is far from standardised in the wild, so you need to do some shimming)
* If no OEmbed, we use open graph
* If no Open Graph, we use title and description

Twitter, Facebook tags and MF2 are not currently used, but are there for future coolness.

Images in Known are also proxied and cached locally for speed and privacy, this proxy also has the ability to transform and resize images. This might be an approach you may want to look at as well, since I found it very useful.

HTH :)