Welcome to mirror list, hosted at ThFree Co, Russian Federation.

title.html « utils « partials « layouts - github.com/reuixiy/hugo-theme-meme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9bc9ebda8ad4909e3ad0797b20e0ba4370c2b269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{{- $ := index . "$" -}}

{{- $path := "" -}}
{{- with .File -}}
    {{- $path = .Path -}}
{{- else -}}
    {{- $path = .Path -}}
{{- end -}}

{{- $htmlTitle := .title -}}
<!-- Home -->
{{- if eq $.Kind "home" -}}
    {{- $htmlTitle = $htmlTitle | default $.Site.Title -}}
<!-- Taxonomy -->
{{- else if eq $.Kind "taxonomy" -}}
    {{- $htmlTitle = $htmlTitle | default ($.Type | title) -}}
<!-- Taxonomy Term -->
{{- else if eq $.Kind "term" -}}
    {{- $taxonomyTermTitle := $htmlTitle | default $.Data.Term | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $path) "/")) " ") -}}
    {{- with $.Site.GetPage (printf "/%s" $.Data.Plural) -}}
        {{- $htmlTitle = printf "%s: %s" (.Title | default (.Type | title)) $taxonomyTermTitle -}}
    {{- end -}}
<!-- Section -->
{{- else if eq $.Kind "section" -}}
    {{- $htmlTitle = $htmlTitle | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $path) "/")) " ") -}}
{{- end -}}

{{- $htmlTitle = partial "utils/markdownify.html" (dict "$" $ "raw" $htmlTitle "isContent" false) -}}

{{- $rawTitle := $htmlTitle | plainify | htmlUnescape -}}

{{- $title := $rawTitle -}}
{{- if ne $.Kind "home" -}}
    {{- $title = printf "%s | %s" $title $.Site.Title -}}
{{- end -}}

{{- return dict "rawTitle" $rawTitle "title" $title "htmlTitle" $htmlTitle -}}