-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Currently to generate the short code in content files we simply do the following in layouts/shortcodes/readme.html:
{{ $data := resources.GetRemote ( printf "https://raw.githubusercontent.com/%s/master/README.md" $.Page.Params.repository) }}
{{ $data.Content | markdownify | safeHTML }}
This hard codes the 'master' branch and can result in potential broken build if only 'main' or another default branch exist.
Currently, even if master does not exist, it will server the main branch, e.g: https://raw.githubusercontent.com/range42/range42/master/README.md
This behaviour might change in the future.
Better would be:
{{ $repo := $.Page.Params.repository }}
{{ $main := resources.GetRemote (printf "https://raw.githubusercontent.com/%s/main/README.md" $repo) }}
{{ with $main }}
{{ .Content | markdownify | safeHTML }}
{{ else }}
{{ $master := resources.GetRemote (printf "https://raw.githubusercontent.com/%s/master/README.md" $repo) }}
{{ with $master }}
{{ .Content | markdownify | safeHTML }}
{{ else }}
{{ warnf "readme shortcode: README.md not found on main or master for repository %s" $repo }}
<p><em>README.md not found for {{ $repo }}.</em></p>
{{ end }}
{{ end }}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels