General go Code Notes
Hugo Custom Shortcode
Add a custom shorcode to display the Github link to the current docs page. (NOTE: the Hugo theme you are looking at does this for you.)
layouts/shortcodes/github-link.html
{{- $repoURL := .Site.Params.docs.repoURL | default "https://github.com/danoand/danodocs-analytics-engineering" -}}
{{- $branch := "main" -}}
{{- $pagePath := .Page.Path -}}
{{- $fileName := replace $pagePath ".html" ".md" -}}
{{- $fileName := cond (eq (substr $fileName 0 1) "/") (substr $fileName 1) $fileName -}}
{{- $githubLink := printf "%s/blob/%s/content/%s" $repoURL $branch $fileName -}}
<hr>
<small>
<a href="{{ $githubLink }}" target="_blank" rel="noopener noreferrer">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-github" viewBox="0 0 16 16">
<path d="M8 0a8 8 0 0 0-2.53 15.588c.4.074.55-.174.55-.386v-1.42c-2.24.486-2.71-1.07-2.71-1.07-.366-.93-.894-1.176-.894-1.176-.73-.5.056-.49.056-.49.807.056 1.303.83 1.303.83.716 1.23 1.88.875 2.34.669a1.67 1.67 0 0 1 .5-1c-2.22-.25-4.56-1.11-4.56-4.94a3.87 3.87 0 0 1 .97-2.68A3.6 3.6 0 0 1 .67 5s-.22-.7-.03-1c0 0 .84-.27 2.75 1a9.42 9.42 0 0 1 5 .001C13 .73 13 .27 13 .27c2 .73 2 .73 2 .73s-.22 .7-.03 .99a3.6 3.6 0 0 1 .97 2.68c0 3.83-2.35 4.68-4.58 4.93a1.67 1.67 0 0 1 .5 .99v1c0 .215 .15 .464 .55 .386A8 8 0 0 0 8 .001z"/>
</svg>
View this page on GitHub
</a>
</small>Reference the shortcode:
\{\{< github-link >\}\}Last updated on