Created
February 6, 2018 00:00
-
-
Save rys/4396450a6585d8f5bc4cb2ee6f323d4e to your computer and use it in GitHub Desktop.
Hugo template to list all posts where you used the Instagram shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
{{ $files := readDir "/content/post" }} | |
{{ range $file := $files }} | |
{{ if in .Name ".md" }} | |
{{ $match := printf "/content/post/%s" .Name | readFile | findRE "{{< instagram" }} | |
{{ if $match }} | |
<li><a href="/post/{{ strings.TrimSuffix ".md" .Name }}">{{ strings.TrimSuffix ".md" .Name }}</a></li> | |
{{ end }} | |
{{ end }} | |
{{ end }} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use the instagram shortcode and want to list them somehow from another page, drop the above into a file in your shortcodes template directory and call it like:
{{< instalist >}}