Currently taking a preliminary look into extracting open graph data from urls, to show previews of urls posted in hugo posts.
From what I see so far the method is to scrape your own page on load, extract the urls, use fetch or ajax to get the open graph data, then write that preview to the html of the dom element, as this stack overflow content suggests:
$.ajax('http://opengraph.io/api/1.0/site/http%3A%2F%2Fwww.washingtontimes.com%2F')
.done(function(data){
console.log(data);
});
Given the og:image and og:url on any given page are static, it would seem sensical to do that directly from Hugo when generating the content.
I.E. write a short code that takes an url and, given an internet connection, fetches the og data and loads to various Hugo variables, which can then be used to preview any og:images, or list any og:titles.
Is this something someone has looked into?