Moondeer
Moondeer

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.

|
Embed
In reply to
sod
sod

@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. šŸ˜”

|
Embed
Moondeer
Moondeer

@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.

|
Embed
sod
sod

@Moondeer I'm glad you found it helpful. šŸ˜Š

|
Embed