Being that Hugo is server-side, were I able to fetch HTML the way I’m able to fetch JSON, I could create a plugin for generating preview cards for external links within posts. Why I’m fixated on thinking up things I could do is beyond me.
Being that Hugo is server-side, were I able to fetch HTML the way I’m able to fetch JSON, I could create a plugin for generating preview cards for external links within posts. Why I’m fixated on thinking up things I could do is beyond me.
@Moondeer It's doable, and fetching is the easy part. "Parsing" is a bit ugly if it's not XHTML. Here's something to get you started:
{{ with resources.GetRemote "https://example.com" }} {{ $meta := findRE "<meta.*?>" .Content }} {{ range $meta }} {{ . }}<br /> {{ end }} {{ end }}
That will output every meta
tag found at the provided URL. Sorry about the messed-up template. 😔
@sod not only is this gonna be a cakewalk now … I'll also be able to replace the use of Javascript with static generation (I think I went to Javascript when there was a race condition as to whether the page existed … only the latest 25 or 30 posts were being successfully cardified. Can't really recall … I was also relearning Javascript).
oh, and coming from Swift … everything Hugo is ugly. I had to get over that rather quickly.