From c5ca5298174f24dc9d8f52ad6e07dfdb96271b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Mon, 18 Mar 2024 21:58:53 +0100 Subject: [PATCH] [theme] introduce relBaseUri #813 --- layouts/partials/relBaseUri.hugo | 10 ++++++++++ layouts/partials/stylesheet.html | 1 + static/js/search.js | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/relBaseUri.hugo diff --git a/layouts/partials/relBaseUri.hugo b/layouts/partials/relBaseUri.hugo new file mode 100644 index 0000000000..b2c6e50147 --- /dev/null +++ b/layouts/partials/relBaseUri.hugo @@ -0,0 +1,10 @@ +{{- /* generates an uphill path from the current page to the root of the server */}} +{{- $subdir := strings.TrimSuffix (relLangURL "/") (relLangURL "") }} +{{- $relBaseUri := .RelPermalink }} +{{- $relBaseUri = replaceRE "/[^/]*$" "" $relBaseUri }} +{{- $relBaseUri = replaceRE "/[^/]*" "/.." $relBaseUri }} +{{- $relBaseUri = trim $relBaseUri "/" }} +{{- if not $relBaseUri }} + {{- $relBaseUri = "." }} +{{- end }} +{{- return $relBaseUri }} \ No newline at end of file diff --git a/layouts/partials/stylesheet.html b/layouts/partials/stylesheet.html index 3c46178820..3952a103c4 100644 --- a/layouts/partials/stylesheet.html +++ b/layouts/partials/stylesheet.html @@ -31,6 +31,7 @@