From 1a9fe22d64d9995432f57996babd51cd6b381c8a Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 4 Aug 2022 21:57:02 +0200 Subject: [PATCH] feat: add option anchor the the bundle menu (#468) --- exampleSite/content/en/usage/menus.md | 4 ++++ layouts/partials/menu-bundle.html | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/exampleSite/content/en/usage/menus.md b/exampleSite/content/en/usage/menus.md index 04f0a7d..d8f154d 100644 --- a/exampleSite/content/en/usage/menus.md +++ b/exampleSite/content/en/usage/menus.md @@ -60,6 +60,10 @@ main: ref: "/level-2/level-2-1" - name: Level 2.2 ref: "/level-2/level-2-2" + - name: Level 2.2 Anchor + ref: /level-2/level-2-2 + # Anchor to add to the entry. This example will result in `/level-2/level-2-2/#anchor` + anchor: anchor ``` As an advantage you can add [icons](/features/icon-sets/) to your menu entries e.g. `icon: "gdoc_notification"`. diff --git a/layouts/partials/menu-bundle.html b/layouts/partials/menu-bundle.html index bb4221b..32d4e5f 100644 --- a/layouts/partials/menu-bundle.html +++ b/layouts/partials/menu-bundle.html @@ -27,6 +27,11 @@ {{ $id := substr (sha1 $this.Permalink) 0 8 }} {{ $doCollapse := and (isset . "sub") (or $this.Params.GeekdocCollapseSection (default false .Site.Params.GeekdocCollapseAllSections)) }} + {{ $anchor := default "" .anchor }} + {{ if $anchor }} + {{ $anchor = printf "#%s" $anchor }} + {{ end }} + {{ if or .external ($this.RelPermalink) }}