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.