From bdc5db79439a5dd15f3779f3b57068438ff22e6d Mon Sep 17 00:00:00 2001 From: Joseph Hale Date: Thu, 9 May 2024 01:40:05 -0700 Subject: [PATCH] refactor: Use `absURL` over `BaseURL` This is the strong recommendation from Hugo since it better handles slashes, i18n, and more: https://gohugo.io/functions/urls/absurl/ --- layouts/shortcodes/maintainer_instructions.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/layouts/shortcodes/maintainer_instructions.md b/layouts/shortcodes/maintainer_instructions.md index 57a6a74..86f1dc3 100644 --- a/layouts/shortcodes/maintainer_instructions.md +++ b/layouts/shortcodes/maintainer_instructions.md @@ -1,17 +1,22 @@ +{{ $alt_text := replace ( .Get "slug") "-" " " | title }} +{{ $slug := ( .Get "slug" ) }} +{{ $article_url := ( absURL $slug ) }} +{{ $badge_url := ( absURL ( printf "%s%s" $slug "/badge.svg" ) ) }} + ## Maintainers Here's how to add the badge for this Public Service Announcement to your README -[![](badge.svg)]({{ .Get "slug" }}.md) +[![](badge.svg)]({{ $slug }}.md) **Markdown** ``` -[![{{ replace ( .Get "slug") "-" " " | title }}]({{ .Page.Site.BaseURL }}{{ .Get "slug" }}/badge.svg)]({{ .Page.Site.BaseURL }}{{ .Get "slug" }}) +[![{{ $alt_text }}]({{ $badge_url }})]({{ $article_url }}) ``` **ReStructured text** ``` -.. image:: {{ .Page.Site.BaseURL }}{{ .Get "slug" }}/badge.svg - :target: {{ .Page.Site.BaseURL }}{{ .Get "slug" }} - :alt: {{ replace ( .Get "slug") "-" " " | title }} +.. image:: {{ $badge_url }} + :target: {{ $article_url }} + :alt: {{ $alt_text }} ``` \ No newline at end of file -- 2.51.2