summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-08 15:44:18 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-08 15:44:18 +0200
commit1f6ece84ae9d201271506a4672ecf86d0a952658 (patch)
treec26fc6bf612337bbe1548ca9c60e10f9f56aa610
parentb4f61294a8865c6279dd55f30dbccf4b11b7167d (diff)
downloadgohugo-theme-ed-1f6ece84ae9d201271506a4672ecf86d0a952658.tar.gz
Rework sidebar
-rw-r--r--exampleSite/config.toml29
-rw-r--r--layouts/partials/sidebar.html13
2 files changed, 25 insertions, 17 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index fe73083..9d9ca60 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -20,8 +20,6 @@ resourceDir = '../resources'
description = 'Ed is a Hugo theme designed for textual editors based on minimal computing principles, and focused on legibility and flexibility.'
# Color scheme. Options: red, orange, magenta, cyan, blue, brown
color_scheme = ''
- # Github project url. Used in sidebar
- github_url = 'https://github.com/sergeyklay/gohugo-theme-ed'
# Used in site header
tagline = 'a Hugo theme for minimal editions'
@@ -40,18 +38,33 @@ resourceDir = '../resources'
facebook_id = ''
[menu]
- [[menu.nav]]
+ [[menu.main]]
+ identifier = 'home'
+ name = 'Home'
+ url = '/'
+ weight = 1
+ [[menu.main]]
+ identifier = 'about'
name = 'About'
url = '/about/'
- weight = 1
- [[menu.nav]]
+ weight = 2
+ [[menu.main]]
+ identifier = 'credits'
name = 'Credits'
url = '/credits/'
- weight = 2
- [[menu.nav]]
+ weight = 3
+ [[menu.main]]
+ identifier = 'documentation'
name = 'Documentation'
url = '/documentation/'
- weight = 3
+ weight = 4
+ [[menu.main]]
+ identifier = 'github'
+ name = 'GitHub Project'
+ url = 'https://github.com/sergeyklay/gohugo-theme-ed/'
+ weight = 20
+ [menu.main.params]
+ external = true
[markup]
[markup.highlight]
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index f46c663..d9f64e1 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -8,22 +8,17 @@
</div>
<nav class="sidebar-nav">
- <a class="sidebar-nav-item{{- if .IsHome }} active{{ end -}}" href="{{ site.Home.RelPermalink }}">Home</a>
-
{{- $current := . }}
- {{- /* TODO: Render items dynamically */}}
- {{- range site.Menus.nav }}
- {{- $active := or ($current.IsMenuCurrent "nav" .) ($current.HasMenuCurrent "nav" .) }}
+ {{- range site.Menus.main }}
+ {{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) }}
+ {{- $active = or $active (eq .URL $current.RelPermalink) }}
{{- $active = or $active (eq .Name $current.Title) }}
- <a class="sidebar-nav-item{{ if $active }} active{{ end }}" href="{{ .URL }}">
+ <a class="sidebar-nav-item{{ if $active }} active{{ end }}" href="{{ .URL }}" {{- if eq .Params.external true }} target="_blank" rel="noopener noreferrer"{{ end }}>
{{- $text := print .Name | safeHTML -}}
{{- $text -}}
</a>
{{- end -}}
{{/* TODO: Add hypothesis support */}}
- {{- with site.Params.github_url }}
- <a class="sidebar-nav-item" href="{{ . }}" target="_blank">GitHub project</a>
- {{- end }}
</nav>
<div class="sidebar-item">