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" /> <img src="{{ "svg/menu.svg" | relURL }}" class="book-icon" alt="Menu" />
</label> </label>
<strong>{{ partial "docs/title" . }}</strong> <strong>{{ partial "docs/title-with-icon" . }}</strong>
<label for="toc-control"> <label for="toc-control">
{{ if default true (default .Site.Params.BookToC .Params.BookToC) }} {{ 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 }} /> <input type="checkbox" id="section-{{ md5 .Page }}" class="toggle" {{ if or $current $ancestor }}checked{{ end }} />
<label for="section-{{ md5 .Page }}" class="flex justify-between"> <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 }}"> <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> </a>
</label> </label>
{{ else if .Page.Params.BookHref }} {{ else if .Page.Params.BookHref }}
<a href="{{ .Page.Params.BookHref }}" class="{{ if $current }}active{{ end }}" target="_blank" rel="noopener"> <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> </a>
{{ else if .Page.Content }} {{ else if .Page.Content }}
<a href="{{ .Page.RelPermalink }}" class="{{ if $current }}active{{ end }}"> <a href="{{ .Page.RelPermalink }}" class="{{ if $current }}active{{ end }}">
{{- partial "docs/title" .Page -}} {{- partial "docs/title-with-icon" .Page -}}
</a> </a>
{{ else }} {{ else }}
<span>{{- partial "docs/title" .Page -}}</span> <span>{{- partial "docs/title-with-icon" .Page -}}</span>
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@ -13,7 +13,7 @@
<a href="{{ .URL }}" {{ with .Params.class }}class="{{ . }}"{{ end }} {{ if not .Page }}target="_blank" rel="noopener"{{ end }}> <a href="{{ .URL }}" {{ with .Params.class }}class="{{ . }}"{{ end }} {{ if not .Page }}target="_blank" rel="noopener"{{ end }}>
{{- .Pre -}} {{- .Pre -}}
{{ with .Page }} {{ with .Page }}
{{ partial "docs/title" .Page }} {{ partial "docs/title-with-icon" .Page }}
{{ else }} {{ else }}
{{ .Name }} {{ .Name }}
{{ end }} {{ 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 Accepts Page as context
--> -->
{{ $title := "" }} {{ $title := "" }}
{{ $icon := "" }}
{{ if .Params.Icon }}
{{ $icon = printf "<img src=\"%s\" class=\"book-filetree-icon\" />" .Params.Icon }}
{{ end }}
{{ if .LinkTitle }} {{ if .LinkTitle }}
{{ $title = .LinkTitle }} {{ $title = .LinkTitle }}
{{ else if .Title }} {{ else if .Title }}
@ -18,5 +14,4 @@
{{ $title = .File.BaseFileName | humanize | title }} {{ $title = .File.BaseFileName | humanize | title }}
{{ end }} {{ end }}
{{ $out := printf "%s %s" $icon $title | safeHTML }} {{ return $title }}
{{ return $out }}

View File

@ -2,7 +2,7 @@
{{ range sort .Paginator.Pages }} {{ range sort .Paginator.Pages }}
<article class="markdown book-post"> <article class="markdown book-post">
<h2> <h2>
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a> <a href="{{ .RelPermalink }}">{{ partial "docs/title-with-icon.html" . }}</a>
</h2> </h2>
{{ partial "docs/post-meta" . }} {{ partial "docs/post-meta" . }}
<p> <p>