wincent / masochist

⛓ Website infrastructure for over-engineers
MIT License
78 stars 26 forks source link

Generate fallback og:description #126

Open wincent opened 6 years ago

wincent commented 6 years ago

Consider an article like: https://wincent.com/blog/languages

I didn't define a description, so FB infers this one:

Searching for the Holy Grail2017-7-20I recently came to the conclusion that, when it comes to programming languages, there is no Holy Grail, just a bunch of cups, and perhaps we should just get on with drinking. I've worked with a lot of languages over the years. I started as a 10-year-old writing i...

I think we can do better than that. Basically grab the body, could even grab the HTML of it, then strip the tags to get back to the plain-text. In this case, we could produce a description similar to this:

I recently came to the conclusion that, when it comes to programming languages, there is no Holy Grail, just a bunch of cups, and perhaps we should just get on with drinking. I've worked with a lot of languages over the years. I started as a 10-year-old writing i...

Could optionally use some heuristics like preferring to stop after a period if that won't make the excerpt too short.

See also: