hugo
hugo copied to clipboard
feature request: social media URL parsing
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
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
You can’t get users to input structured data.
I would say you can't get some users to input structured data. Whether or not "some" represents a majority is debatable.
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 }}