hugo-theme-relearn/layouts/partials/output-article.html
2022-07-11 00:59:26 +02:00

12 lines
No EOL
800 B
HTML

{{- $page := .page }}
{{- $content := .content }}
{{- $r_url := $page.RelPermalink }}
{{- with $page.OutputFormats.Get (partial "output-format.html" $page) }}
{{- $s_url := .RelPermalink }}
{{- if not (eq $s_url $r_url) }}
{{/* if we have a relative link in output formats with a path setting, our URLs are one level to deep; so we are making them absolute to our page by prepending the page's permalink */}}
{{- $link_prefix := strings.TrimRight "/" $page.Page.RelPermalink }}
{{- $content = replaceRE "((?:src|href)\\s*=(?:\\s*[\"']\\s*)?)(\\.[^\"'\\s>]*|[\\w]+[^\"'\\s>:]*)([\"'\\s>])" (printf "${1}%s/${2}${3}" $link_prefix) $content }}
{{- end }}
{{- end }}
{{- partial "output-partial.html" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content)) }}