mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-22 03:19:25 +00:00
fix: only use icon where applicable
This commit is contained in:
parent
b43d9fe2bb
commit
5fcb0c09a8
@ -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) }}
|
||||
|
@ -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 }}
|
||||
|
@ -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 }}
|
||||
|
9
layouts/partials/docs/title-with-icon.html
Normal file
9
layouts/partials/docs/title-with-icon.html
Normal 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 }}
|
@ -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 }}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user