diff --git a/layouts/partials/utilities/URLJoin.html b/layouts/partials/utilities/URLJoin.html new file mode 100644 index 00000000..83394a54 --- /dev/null +++ b/layouts/partials/utilities/URLJoin.html @@ -0,0 +1,16 @@ +{{- $base := .base -}} +{{- if not $base }} + {{- errorf "partial [assets/utilities/URLJoin.html] - Expected param 'base'" -}} +{{- end -}} + +{{- $path := .path -}} +{{- if not $path }} + {{- errorf "partial [assets/utilities/URLJoin.html] - Expected param 'path'" -}} +{{- end -}} + +{{- $url := $path -}} +{{- if not (hasPrefix $path "http") -}} + {{- $url = printf "%s/%s" (strings.TrimSuffix "/" $base) $path -}} +{{- end }} + +{{- return $url -}} \ No newline at end of file diff --git a/layouts/shortcodes/release.html b/layouts/shortcodes/release.html index 3389ae34..106a62d7 100644 --- a/layouts/shortcodes/release.html +++ b/layouts/shortcodes/release.html @@ -58,7 +58,7 @@
{{- partial "assets/button.html" (dict "title" $title - "href" (printf "%s/%s" (strings.TrimSuffix "/" site.Params.docs.release) $version) + "href" (partial "partials/utilities/URLJoin.html" (dict "base" site.Params.docs.release "path" $version)) "size" "sm" "color" $color "outline" "true" diff --git a/layouts/shortcodes/timeline.html b/layouts/shortcodes/timeline.html index d2e2720b..ea0250fd 100644 --- a/layouts/shortcodes/timeline.html +++ b/layouts/shortcodes/timeline.html @@ -45,9 +45,9 @@ {{- $badge := .badge -}} {{- $url := .url -}} {{- $date := .date -}} - {{ if and $url (not (hasPrefix $url "http")) }} - {{ $url = path.Join site.Params.docs.release $url }} - {{ end }} + {{- if and $url (not (hasPrefix $url "http")) -}} + {{- $url = partial "partials/utilities/URLJoin.html" (dict "base" site.Params.docs.release "path" $url) }} + {{- end -}} {{- $direction := .direction -}}
@@ -59,7 +59,7 @@ {{ $title }} {{ if $badge }}{{ $badge }}{{ end }} {{ else}} - {{ $title }} + {{ $title }} {{ if $badge }}{{ $badge }}{{ end }} {{ end }}
diff --git a/package-lock.json b/package-lock.json index 60ec1327..31feb7ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gethinode/hinode", - "version": "0.15.4", + "version": "0.15.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gethinode/hinode", - "version": "0.15.4", + "version": "0.15.5", "license": "MIT", "devDependencies": { "@fortawesome/fontawesome-free": "^6.4.0", diff --git a/package.json b/package.json index 95e9225a..a632814b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gethinode/hinode", - "version": "0.15.4", + "version": "0.15.5", "description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator", "keywords": [ "hugo",