From 8d75e9e27a763876b452323132fc8a1eb28bf034 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Wed, 17 Jun 2020 20:29:03 +0100 Subject: [PATCH] feat: add options to highlight active links and show current language `highlight_active_link` and `show_language` added to `main_menu` in `params.toml`: `main_menu = {align = "l", show_logo = true, highlight_active_link = true, show_language = false}` For example, enables disabling highlighting active main menu links on scroll if it's found to be inaccurate in a certain case, such as towards the end of a homepage with lots of very short widgets that are linked in the menu. --- exampleSite/config/_default/params.toml | 2 +- layouts/_default/baseof.html | 4 +++- layouts/partials/navbar.html | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 52fc2167..856283e0 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -147,7 +147,7 @@ address_format = "en-us" ############################ # Main menu alignment (l = left, c = center, r = right) and logo options. -main_menu = {align = "l", show_logo = true} +main_menu = {align = "l", show_logo = true, highlight_active_link = true, show_language = false} # Show estimated reading time for posts? (true/false) reading_time = true diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 249dba8a..0b6f86dc 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -3,7 +3,9 @@ {{ partial "site_head" . }} - + +{{- $highlight_active_link := site.Params.main_menu.highlight_active_link | default true -}} + {{ partial "search" . }} diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index 236ffd13..c2320fd8 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -1,4 +1,6 @@ {{ $current_page := . }} +{{ $highlight_active_link := site.Params.main_menu.highlight_active_link | default true }} +{{ $show_current_language := site.Params.main_menu.show_language | default false }} {{/* Get site logo. */}} {{ $show_logo := site.Params.main_menu.show_logo | default true }} @@ -90,7 +92,7 @@ {{ end }} @@ -151,8 +153,11 @@ {{ if .IsTranslated }}