hugo-theme-contentful/layouts/_default/single.html

52 lines
1.8 KiB
HTML
Raw Normal View History

2019-09-20 16:11:12 +00:00
{{ define "main" }}
2020-05-09 07:19:04 +00:00
<header>
<h1>{{ .Title }}</h1>
<div class="post__meta">
<!-- List the author(s) of the article. -->
{{- with .Params.author }}
2020-05-11 15:59:06 +00:00
{{- $names := slice }}
{{- range . }}{{ $names = $names | append .name }}{{ end }}
2020-05-13 18:54:02 +00:00
<p class="author">{{ i18n "published_by" }}: {{ delimit $names ", " (printf " %s " (i18n "and")) }}</p>
2020-05-09 07:19:04 +00:00
{{- end }}
2020-05-11 15:59:06 +00:00
<!-- Only show the creation date if the `date` field is valid. -->
{{- if ne (.Date.Format "2006") "0001" }}
2020-05-09 07:19:04 +00:00
<!-- Publication date. -->
<p class="created-date">{{ i18n "published_on" }}: <date datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</date></p>
2020-05-11 15:59:06 +00:00
{{- end }}
2020-05-09 07:19:04 +00:00
<!-- Modification date (will only appear if the publication date is less than the modified date.) -->
{{- if ne .Date .Lastmod }}
<p class="updated-date">{{ i18n "updated_on" }}: <date datetime="{{ .Lastmod.Format "2006-01-02" }}">{{ .Lastmod.Format "2006-01-02" }}</date></p>
{{- end }}
<!-- Link the translated versions if the article has at least one translated page. -->
{{- if .IsTranslated }}
2020-05-13 18:54:02 +00:00
{{ $langs := slice }}
{{ range .Translations }}{{ $langs = $langs | append (printf "<a href=%s>%s</a>" .Permalink (cond (ne .Language.LanguageName nil) .Language.LanguageName .Lang)) }}{{ end }}
<p>{{ i18n "available_translations" }}: {{ delimit $langs "," (printf " %s " (i18n "and")) }}</p>
2020-05-09 07:19:04 +00:00
{{- end }}
</div>
</header>
2019-09-20 16:11:12 +00:00
<hr>
2020-05-09 07:19:04 +00:00
{{ $is_toc := cond (ne .Params.toc nil) .Params.toc $.Site.Params.toc }}
{{ if $is_toc }}
2020-10-21 03:28:02 +00:00
<style>
#TableOfContents:not(:empty)::before {
content: "{{ i18n "table_of_contents" }}";
font-weight: bold;
}
</style>
2020-05-09 07:19:04 +00:00
{{ .TableOfContents }}
{{ end }}
2019-09-20 16:11:12 +00:00
<article>
{{ .Content }}
</article>
2020-05-09 07:19:04 +00:00
{{ end }}