From 42d3c650f80d027bdac53c0a1b9d103e582203e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dav=C3=B3?= Date: Fri, 6 Oct 2023 20:38:18 +0200 Subject: [PATCH] Fixed navbar scroll spy (#798) (#799) * Fixed navbar scroll spy * Created get-section-url helper * Fix URL for home section Signed-off-by: hossainemruz --------- Signed-off-by: hossainemruz Co-authored-by: Emruz Hossain --- assets/styles/layouts/main.scss | 4 ++++ layouts/partials/helpers/get-section-url.html | 5 +++++ layouts/partials/navigators/navbar.html | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 layouts/partials/helpers/get-section-url.html diff --git a/assets/styles/layouts/main.scss b/assets/styles/layouts/main.scss index 96cef8d..eb30ce8 100644 --- a/assets/styles/layouts/main.scss +++ b/assets/styles/layouts/main.scss @@ -8,6 +8,10 @@ html { scroll-behavior: smooth !important; } +body { + position: relative; +} + /* Fixes anchor overlapping with header. See: https://stackoverflow.com/questions/4086107/fixed-page-header-overlaps-in-page-anchors diff --git a/layouts/partials/helpers/get-section-url.html b/layouts/partials/helpers/get-section-url.html new file mode 100644 index 0000000..2a902f4 --- /dev/null +++ b/layouts/partials/helpers/get-section-url.html @@ -0,0 +1,5 @@ +{{- if page.IsHome -}} + #{{ partial "helpers/get-section-id.html" . }} +{{- else -}} + {{ site.BaseURL | relLangURL }}#{{ partial "helpers/get-section-id.html" . }} +{{- end -}} \ No newline at end of file diff --git a/layouts/partials/navigators/navbar.html b/layouts/partials/navigators/navbar.html index 57f3a8e..d10a78e 100644 --- a/layouts/partials/navigators/navbar.html +++ b/layouts/partials/navigators/navbar.html @@ -77,9 +77,9 @@