Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: doc pages can have icons shown before the title in the menu #572

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions assets/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ body[dir="rtl"] .book-menu {
will-change: transform, margin, opacity;
}

.book-filetree-icon {
width: 16px;
height: 16px;
vertical-align: middle;
}

@media screen and (max-width: $mobile-breakpoint) {
#menu-control,
#toc-control {
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/docs/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img src="{{ "svg/menu.svg" | relURL }}" class="book-icon" alt="Menu" />
</label>

<strong>{{ partial "docs/title" . }}</strong>
<strong>{{ partial "docs/title-with-icon" . }}</strong>

<label for="toc-control">
{{ if default true (default .Site.Params.BookToC .Params.BookToC) }}
Expand Down
8 changes: 4 additions & 4 deletions layouts/partials/docs/menu-filetree.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
<input type="checkbox" id="section-{{ md5 .Page }}" class="toggle" {{ if or $current $ancestor }}checked{{ end }} />
<label for="section-{{ md5 .Page }}" class="flex justify-between">
<a {{ if .Page.Content }}href="{{ .Page.RelPermalink }}"{{ else }}role="button"{{ end }} class="{{ if $current }}active{{ end }}">
{{- partial "docs/title" .Page -}}
{{- partial "docs/title-with-icon" .Page -}}
</a>
</label>
{{ else if .Page.Params.BookHref }}
<a href="{{ .Page.Params.BookHref }}" class="{{ if $current }}active{{ end }}" target="_blank" rel="noopener">
{{- partial "docs/title" .Page -}}
{{- partial "docs/title-with-icon" .Page -}}
</a>
{{ else if .Page.Content }}
<a href="{{ .Page.RelPermalink }}" class="{{ if $current }}active{{ end }}">
{{- partial "docs/title" .Page -}}
{{- partial "docs/title-with-icon" .Page -}}
</a>
{{ else }}
<span>{{- partial "docs/title" .Page -}}</span>
<span>{{- partial "docs/title-with-icon" .Page -}}</span>
{{ end }}
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/docs/menu-hugo.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<a href="{{ .URL }}" {{ with .Params.class }}class="{{ . }}"{{ end }} {{ if not .Page }}target="_blank" rel="noopener"{{ end }}>
{{- .Pre -}}
{{ with .Page }}
{{ partial "docs/title" .Page }}
{{ partial "docs/title-with-icon" .Page }}
{{ else }}
{{ .Name }}
{{ end }}
Expand Down
9 changes: 9 additions & 0 deletions layouts/partials/docs/title-with-icon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ $title := (partial "docs/title" .) }}
{{ $icon := "" }}

{{ if .Params.Icon }}
{{ $icon = printf "<img src=\"%s\" class=\"book-filetree-icon\" />" .Params.Icon }}
{{ end }}

{{ $out := printf "%s %s" $icon $title | safeHTML }}
{{ return $out }}
2 changes: 1 addition & 1 deletion layouts/posts/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ range sort .Paginator.Pages }}
<article class="markdown book-post">
<h2>
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
<a href="{{ .RelPermalink }}">{{ partial "docs/title-with-icon.html" . }}</a>
</h2>
{{ partial "docs/post-meta" . }}
<p>
Expand Down