From a53ba7dd45c163d5fafc24e3784f72791574fd21 Mon Sep 17 00:00:00 2001 From: Robert Fekete Date: Wed, 25 May 2022 10:33:43 +0200 Subject: [PATCH 1/2] Scroll left toc to active entry Useful when the left-side toc is longer than the screen. Fixes https://github.com/google/docsy/issues/348 and https://github.com/google/docsy/issues/257 This is an update of the original patch of narrenfrei --- layouts/partials/sidebar-tree.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/layouts/partials/sidebar-tree.html b/layouts/partials/sidebar-tree.html index 258267b005..781e778c93 100644 --- a/layouts/partials/sidebar-tree.html +++ b/layouts/partials/sidebar-tree.html @@ -53,9 +53,9 @@
  • {{ if (and $p.Site.Params.ui.sidebar_menu_foldable (ge $ulNr 1)) -}} - + {{ else -}} - {{ with $s.Params.Icon}}{{ end }}{{ $s.LinkTitle }} + {{ with $s.Params.Icon}}{{ end }}{{ $s.LinkTitle }} {{- end }} {{- if $withChild }} {{- $ulNr := add $ulNr 1 }} @@ -68,4 +68,9 @@ {{- end }}
  • -{{- end }} \ No newline at end of file +{{- end }} + + \ No newline at end of file From 10e09ab099e85f955d89ec711fff11a46bc53e99 Mon Sep 17 00:00:00 2001 From: Robert Fekete Date: Thu, 22 Sep 2022 16:40:55 +0200 Subject: [PATCH 2/2] Add id to active span element --- layouts/partials/sidebar.html | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 8d3fc5ae7b..43a7c714c8 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -9,6 +9,7 @@ $("#td-section-nav a").removeClass("active"); $("#td-section-nav #{{ $mid }}").addClass("active"); $("#td-section-nav #{{ $mid }}-li span").addClass("td-sidebar-nav-active-item"); + $("#td-section-nav #{{ $mid }}-li span").attr("id", "td-sidebar-nav-active-item"); $("#td-section-nav #{{ $mid }}").parents("li").addClass("active-path"); $("#td-section-nav li.active-path").addClass("show"); $("#td-section-nav li.active-path").children("input").prop('checked', true);