Allow the menu to specify a style for the item

Style changes the trailing character, a la ls -F. The default is 'dir', appending
a slash `/`. You can also specify 'file' to append a '*'.
This commit is contained in:
Eryn Wells 2024-10-20 09:18:34 -07:00
parent 60db7eeb03
commit 50dc3c45c1
2 changed files with 33 additions and 19 deletions

View file

@ -41,13 +41,15 @@
text-decoration: none; text-decoration: none;
} }
} }
}
.site-header__nav {
.site-nav {
font-size: var(--text-m); font-size: var(--text-m);
font-weight: normal; font-weight: normal;
ul { ul {
--spacing: 1ch; --spacing: 2ch;
display: flex; display: flex;
gap: var(--spacing); gap: var(--spacing);
@ -55,16 +57,22 @@
margin: 0; margin: 0;
padding: 0; padding: 0;
li { .site-nav__item {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
li::after { .site-nav__item::after {
color: var(--color-nav-separator); color: var(--color-nav-separator);
content: "/";
justify-content: center; justify-content: center;
} }
:is(.site-nav__item, .site-nav__item--dir)::after {
content: "/";
}
.site-nav__item--file::after {
content: "*";
} }
} }
} }

View file

@ -11,7 +11,7 @@ Renders a menu for the given menu ID.
{{- $menuID := .menuID }} {{- $menuID := .menuID }}
{{- with index site.Menus $menuID }} {{- with index site.Menus $menuID }}
<nav class="site-header__nav"> <nav class="site-nav">
<ul> <ul>
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }} {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
</ul> </ul>
@ -33,7 +33,13 @@ Renders a menu for the given menu ID.
{{- $name = . }} {{- $name = . }}
{{- end }} {{- end }}
{{- end }} {{- end }}
<li>{{- "" -}} <li
{{- with .Params.style }}
class="site-nav__item site-nav__item--{{ . }}"
{{ else }}
class="site-nav__item site-nav__item--dir"
{{ end -}}
>{{- "" -}}
<a <a
{{- range $k, $v := $attrs }} {{- range $k, $v := $attrs }}
{{- with $v }} {{- with $v }}