mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-22 05:00:39 +00:00
feat: add optional extra menu to site navigations (#26)
* feat: add optional extra menu to site navigations * add extra menu documentation * rename menu to menu-extra * feat: add optional extra menu to site navigations * add extra menu documentation * rename menu to menu-extra * fix spellcheck
This commit is contained in:
parent
9d9a5cf557
commit
82f95b1766
@ -11,6 +11,7 @@ emojify
|
|||||||
img
|
img
|
||||||
JSON
|
JSON
|
||||||
SVG
|
SVG
|
||||||
|
YAML
|
||||||
pre-processor
|
pre-processor
|
||||||
pre-build
|
pre-build
|
||||||
submodule
|
submodule
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Legal Notice"
|
|
||||||
---
|
|
@ -429,3 +429,25 @@ geekblogAnchor: true
|
|||||||
|
|
||||||
{{< /tab >}}
|
{{< /tab >}}
|
||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
## Menus
|
||||||
|
|
||||||
|
### Extra menu
|
||||||
|
|
||||||
|
If you want to customize the menus (header and footer), this can be achieved by a data file. This file needs to be written in YAML and placed at data/menu/extra.yml.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```Yaml
|
||||||
|
---
|
||||||
|
header:
|
||||||
|
- name: Github Profile
|
||||||
|
icon: github
|
||||||
|
ref: "https://github.com/xoxys"
|
||||||
|
external: true
|
||||||
|
|
||||||
|
footer:
|
||||||
|
- name: Contact
|
||||||
|
icon: email
|
||||||
|
ref: "/contact"
|
||||||
|
```
|
||||||
|
11
exampleSite/data/menu/extra.yml
Normal file
11
exampleSite/data/menu/extra.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
header:
|
||||||
|
- name: Github Profile
|
||||||
|
icon: github
|
||||||
|
ref: "https://github.com/xoxys"
|
||||||
|
external: true
|
||||||
|
|
||||||
|
footer:
|
||||||
|
- name: Contact
|
||||||
|
icon: email
|
||||||
|
ref: "/contact"
|
35
layouts/partials/menu-extra.html
Normal file
35
layouts/partials/menu-extra.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{{ $current := .current }}
|
||||||
|
{{ template "menu-file" dict "sect" .source "current" $current "site" $current.Site "target" .target }}
|
||||||
|
|
||||||
|
<!-- template -->
|
||||||
|
{{ define "menu-file" }}
|
||||||
|
{{ $current := .current }}
|
||||||
|
{{ $site := .site }}
|
||||||
|
{{ $target := .target }}
|
||||||
|
|
||||||
|
{{ range sort (default (seq 0) .sect) "weight" }}
|
||||||
|
{{ if isset . "ref" }}
|
||||||
|
{{ $this := $site.GetPage .ref }}
|
||||||
|
{{ $isCurrent := eq $current $this }}
|
||||||
|
{{ $icon := default false .icon }}
|
||||||
|
|
||||||
|
{{ if eq $target "footer" }}
|
||||||
|
<span class="gblog-footer__item">
|
||||||
|
{{ if $icon }}<svg class="icon {{ .icon }}"><use xlink:href="#{{ .icon }}"></use></svg>{{ end }}
|
||||||
|
<a href="{{ if .external }}{{ .ref }}{{ else }}{{ relref $current .ref }}{{ end }}"
|
||||||
|
class="gblog-footer__link">
|
||||||
|
{{ .name }}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
{{ else if eq $target "header" }}
|
||||||
|
<li>
|
||||||
|
<a href="{{ if .external }}{{ .ref }}{{ else }}{{ relref $current .ref }}{{ end }}"
|
||||||
|
class="gblog-nav__entry {{ if $isCurrent }}is-active{{ end }}">
|
||||||
|
{{ if $icon }}<svg class="icon {{ .icon }}"><use xlink:href="#{{ .icon }}"></use></svg>{{ end }}
|
||||||
|
{{ .name }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
@ -1,17 +1,14 @@
|
|||||||
<footer class="gblog-footer">
|
<footer class="gblog-footer">
|
||||||
<div class="container">
|
<nav class="container">
|
||||||
<div class="flex flex-wrap align-center">
|
<section class="flex flex-wrap align-center">
|
||||||
{{ with (.Site.GetPage "home").OutputFormats.Get "atom" }}
|
{{ with (.Site.GetPage "home").OutputFormats.Get "atom" }}
|
||||||
<span class="gblog-footer__item">
|
<span class="gblog-footer__item">
|
||||||
<svg class="icon rss_feed"><use xlink:href="#rss_feed"></use></svg>
|
<svg class="icon rss_feed"><use xlink:href="#rss_feed"></use></svg>
|
||||||
<a href='{{ .Permalink | relURL }}' class="gblog-footer__link">Feed</a>
|
<a href='{{ .Permalink | relURL }}' class="gblog-footer__link">Atom Feed</a>
|
||||||
</span>
|
</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ with .GetPage "contact.md" }}
|
{{ if .Site.Data.menu.extra.footer }}
|
||||||
<span class="gblog-footer__item">
|
{{ partial "menu-extra" (dict "current" . "source" .Site.Data.menu.extra.footer "target" "footer") }}
|
||||||
<svg class="icon email"><use xlink:href="#email"></use></svg>
|
|
||||||
<a href='{{ .Permalink | relURL }}' class="gblog-footer__link">Contact</a>
|
|
||||||
</span>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ with .Site.Params.GeekblogLegalNotice }}
|
{{ with .Site.Params.GeekblogLegalNotice }}
|
||||||
<span class="gblog-footer__item">
|
<span class="gblog-footer__item">
|
||||||
@ -23,24 +20,19 @@
|
|||||||
<a href="{{ . | relURL }}" class="gblog-footer__link">Privacy Policy</a>
|
<a href="{{ . | relURL }}" class="gblog-footer__link">Privacy Policy</a>
|
||||||
</span>
|
</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ with .Site.Params.GeekblogContentLicense }}
|
</section>
|
||||||
<span class="gblog-footer__item">
|
<section class="flex flex-wrap align-center">
|
||||||
Content licensed under <a href="{{ .link }}" class="gblog-footer__link no-wrap">{{ .name }}</a>
|
|
||||||
</span>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-wrap align-center">
|
|
||||||
<span class="gblog-footer__item">
|
<span class="gblog-footer__item">
|
||||||
Built with <a href="https://gohugo.io/" class="gblog-footer__link">Hugo</a> and
|
Built with <a href="https://gohugo.io/" class="gblog-footer__link">Hugo</a> and
|
||||||
<svg class="icon heart"><use xlink:href="#heart"></use></svg>
|
<svg class="icon heart"><use xlink:href="#heart"></use></svg>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</section>
|
||||||
{{ with .Site.Params.GeekblogHostedOn }}
|
{{ with .Site.Params.GeekblogHostedOn }}
|
||||||
<div class="flex flex-wrap align-center">
|
<section class="flex flex-wrap align-center">
|
||||||
<span class="gblog-footer__item">
|
<span class="gblog-footer__item">
|
||||||
Hosted on <a href="{{ .link }}" class="gblog-footer__link">{{ .name }}</a>
|
Hosted on <a href="{{ .link }}" class="gblog-footer__link">{{ .name }}</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</section>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</nav>
|
||||||
</footer>
|
</footer>
|
||||||
|
@ -29,5 +29,8 @@
|
|||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if .Site.Data.menu.extra.header }}
|
||||||
|
{{ partial "menu-extra" (dict "current" . "source" .Site.Data.menu.extra.header "target" "header") }}
|
||||||
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
Loading…
Reference in New Issue
Block a user