hugo-theme-contentful/layouts/_default/single.html
2020-05-11 23:59:06 +08:00

50 lines
1.6 KiB
HTML

{{ define "main" }}
<header>
<h1>{{ .Title }}</h1>
<div class="post__meta">
<!-- List the author(s) of the article. -->
{{- with .Params.author }}
{{- $names := slice }}
{{- range . }}{{ $names = $names | append .name }}{{ end }}
<p class="author">{{ i18n "published_by" }}: {{ delimit $names ", " ", and " }}</p>
{{- end }}
<!-- Only show the creation date if the `date` field is valid. -->
{{- if ne (.Date.Format "2006") "0001" }}
<!-- Publication date. -->
<p class="created-date">{{ i18n "published_on" }}: <date datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</date></p>
{{- end }}
<!-- 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 }}
<p>
{{- i18n "available_translations" }}:
|
{{ range .Translations }}
<a href="{{ .Permalink }}">{{ with .Language.LanguageName }}{{ . }}{{ else }}{{ .Lang }}{{ end }}</a> |
{{- end }}
</p>
{{- end }}
</div>
</header>
<hr>
{{ $is_toc := cond (ne .Params.toc nil) .Params.toc $.Site.Params.toc }}
{{ if $is_toc }}
{{ .TableOfContents }}
{{ end }}
<article>
{{ .Content }}
</article>
{{ end }}