hugo icon indicating copy to clipboard operation
hugo copied to clipboard

feature request: social media URL parsing

Open earthboundkid opened this issue 1 year ago • 4 comments

I have written Hugo sites where users can add social URLs. It would be nice if Hugo had a way to automatically parse them, so I can display {{ .username }} instead of http://example.com/username. You can do one off parsing for known sites like Facebook and Twitter if you know that's what it is ahead of time, but it's a lot of logic to shove into a template.

This project does the legwork already, so if it were added as a dependency, all that Hugo would have to do is expose it in the template function: https://github.com/FurqanSoftware/slinky

earthboundkid avatar Oct 19 '23 20:10 earthboundkid

Is this template function for convenience, instead of doing this in site configuration or on term page (e.g., content/authors/jmooring/_index.md)?

params:
  - social:
      handle: '@jmooring'
      url: https://github.com/jmooring/
  - social:
      handle: '@jmooring'
      url: https://social.vivaldi.net/@jmooring

jmooring avatar Oct 19 '23 21:10 jmooring

You can’t get users to input structured data.

earthboundkid avatar Oct 20 '23 05:10 earthboundkid

I would say you can't get some users to input structured data. Whether or not "some" represents a majority is debatable.

jmooring avatar Oct 20 '23 06:10 jmooring

I like this, and the library in question looks small and simple enough. I think there are plenty of Hugo use cases where the author struct could have a

links:
 -  https://github.com/jmooring/
  - https://social.vivaldi.net/@jmooring

Having a simple way to present that info would have value enough considering how relatively simple it would be to implement.

I guess something like this would make sense?

{{ with urls.ParseSocial $link }}
Service: {{ .Service }}
UserID: {{ .ID }}
{{ else }}
// Unknown URL format.
{{ end }}

bep avatar Oct 20 '23 07:10 bep