mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-31 11:45:26 +01:00 
			
		
		
		
	menu : add menu location indicator
credits for fix with [.IsMenuCurrent](https://gohugo.io/functions/ismenucurrent/): https://stackoverflow.com/a/56454338
This commit is contained in:
		| @@ -38,4 +38,9 @@ | ||||
|  | ||||
| .menu a { | ||||
|     font-size: 16px; | ||||
| } | ||||
|  | ||||
| .menu .active { | ||||
|     font-weight: 500; | ||||
|     border-bottom: 2px solid currentColor; | ||||
| } | ||||
| @@ -8,7 +8,7 @@ | ||||
| <body | ||||
|     class="{{ if (and (eq .Kind `page` ) (ne .Layout `archives`)) }}single{{ else }}list{{ if .IsHome }} home {{ end }}{{ end }}{{ if eq $.Site.Params.defaultTheme `dark` }} dark {{ end }}" | ||||
|     id="top"> | ||||
|     {{- partialCached "header.html" . }} | ||||
|     {{- partialCached "header.html" . .Page}} | ||||
|     <main class="main"> | ||||
|         {{- block "main" . }} | ||||
|         {{end }} | ||||
|   | ||||
| @@ -12,14 +12,19 @@ | ||||
|         {{- else }} | ||||
|         <p class="logo"><a href="{{ "" | absLangURL }}">{{ .Site.Title }}</a></p> | ||||
|         {{- end }} | ||||
|         {{- if .Site.Menus.main }} | ||||
|         {{ $currentPage := . }} | ||||
|         <ul class="menu" id="menu" onscroll="menu_on_scroll()"> | ||||
|             {{- range .Site.Menus.main }} | ||||
|             {{ $menu_item_url := .URL | relLangURL }} | ||||
|             {{ $page_url:= $currentPage.RelPermalink | relLangURL }} | ||||
|             <li> | ||||
|                 <a href="{{ .URL | absLangURL}}">{{ .Name }}</a> | ||||
|                 <a href="{{ .URL | absLangURL }}"> | ||||
|                     <span {{ if eq $menu_item_url $page_url }} | ||||
|                         {{/* the menu item links to the current page (with relLangURL) */}} class="active" | ||||
|                         {{ end }}>{{ .Name }}</span> | ||||
|                 </a> | ||||
|             </li> | ||||
|             {{- end }} | ||||
|         </ul> | ||||
|         {{- end }} | ||||
|     </nav> | ||||
| </header> | ||||
		Reference in New Issue
	
	Block a user
	 Aditya Telange
					Aditya Telange