feat: add params.navbar_style to config to select a style for the navbar (#14)

This is a new feature in readable.css 1.1.0. The new version of
readable.css defaults to a navbar without animations, but to stay
compatible with older releases of this theme, we default to "classy"
instead which is the animated navbar.

The new navbar styles also look better without wrapping the elements
inside a `<span>`, so we make that conditional and only apply it when
the "classy" style is chosen.
This commit is contained in:
Robert Lützner 2023-05-18 01:13:27 +00:00 committed by GitHub
parent e0098cfafd
commit bbbc85d824
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -1,10 +1,15 @@
<h1>{{ $.Site.Title }}</h1>
<p>{{ $.Site.Params.subtitle }}</p>
<nav data-style="classy">
<!-- readable.css v1.1.0 introduced different navbar styles and defaults to a
navbar without animations. We default to "classy" to keep the animations and be
backwards compatible to earlier versions of this theme without requiring a
config change. -->
{{ $navbar_style := (default "classy" $.Site.Params.navbar_style) }}
<nav data-style={{ $navbar_style }}>
{{ range .Site.Menus.main -}}
<span>
{{ if eq $navbar_style "classy" }}<span>{{ end }}
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
</span>
{{ if eq $navbar_style "classy" }}</span>{{ end }}
{{- end }}
</nav>