mirror of
				https://github.com/adityatelange/hugo-PaperMod.git
				synced 2025-11-04 10:22:44 +01:00 
			
		
		
		
	credits for fix with [.IsMenuCurrent](https://gohugo.io/functions/ismenucurrent/): https://stackoverflow.com/a/56454338
		
			
				
	
	
		
			30 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{{ if eq .Site.Params.defaultTheme "auto" }}
 | 
						|
<script>
 | 
						|
    if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
 | 
						|
        document.body.classList.add('dark');
 | 
						|
    }
 | 
						|
</script>
 | 
						|
{{ end }}
 | 
						|
<header class="header">
 | 
						|
    <nav class="nav">
 | 
						|
        {{- if .IsHome }}
 | 
						|
        <h1 class="logo"><a href="{{ "" | absLangURL }}">{{ .Site.Title }}</a></h1>
 | 
						|
        {{- else }}
 | 
						|
        <p class="logo"><a href="{{ "" | absLangURL }}">{{ .Site.Title }}</a></p>
 | 
						|
        {{- end }}
 | 
						|
        {{ $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 }}">
 | 
						|
                    <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>
 | 
						|
    </nav>
 | 
						|
</header> |