fix: only use icon where applicable

This commit is contained in:
Gabriele Musco 2023-12-10 09:16:12 +00:00
parent b43d9fe2bb
commit 5fcb0c09a8
6 changed files with 17 additions and 13 deletions

View File

@ -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) }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -3,11 +3,7 @@
Accepts Page as context
-->
{{ $title := "" }}
{{ $icon := "" }}
{{ if .Params.Icon }}
{{ $icon = printf "<img src=\"%s\" class=\"book-filetree-icon\" />" .Params.Icon }}
{{ end }}
{{ if .LinkTitle }}
{{ $title = .LinkTitle }}
{{ else if .Title }}
@ -18,5 +14,4 @@
{{ $title = .File.BaseFileName | humanize | title }}
{{ end }}
{{ $out := printf "%s %s" $icon $title | safeHTML }}
{{ return $out }}
{{ return $title }}

View File

@ -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>