feat: add last updated component

chore: option to reverse pagination

chore: reverse pagination for blog entries

- fix space for "by" authors
This commit is contained in:
Xin 2023-08-09 22:36:20 +01:00
parent a7aa9fa1cb
commit ad3c607623
4 changed files with 20 additions and 9 deletions

View File

@ -9,15 +9,15 @@
{{ with $date := .Date }}
<div class="mt-4 mb-16 text-gray-500 text-sm">
{{ partial "utils/format-date" $date }}
{{- if $.Params.authors }} by {{ end -}}
{{- with $.Params.authors }}
{{- if $.Params.authors }}&nbsp;by&nbsp;{{ end -}}
{{- with $.Params.authors -}}
{{- range $i, $author := . -}}
{{- if $i }},{{ end -}}
{{- if $author.link }}
{{- if $author.link -}}
<a href="{{ $author.link }}" target="_blank" class="mx-1 text-current underline [text-underline-position:from-font] decoration-from-font">{{ $author.name }}</a>
{{ else }}
{{- else -}}
<span>{{ $author.name }}</span>
{{ end -}}
{{- end -}}
{{- end -}}
{{- end -}}
</div>
@ -25,7 +25,8 @@
<div class="content">
{{ .Content }}
</div>
<div class="mt-16"></div>
{{ partial "components/last-updated.html" . }}
{{ .Scratch.Set "reversePagination" true }}
{{ partial "pager.html" . }}
</main>
</article>

View File

@ -9,7 +9,7 @@
<h1>{{ .Title }}</h1>
{{ .Content }}
</div>
<div class="mt-16"></div>
{{ partial "components/last-updated.html" . }}
{{ partial "pager.html" . }}
</main>
</article>

View File

@ -0,0 +1,8 @@
{{ if site.Params.displayUpdatedDate }}
{{- with .Lastmod -}}
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
<div class="mt-12 mb-8 block text-xs text-gray-500 ltr:text-right rtl:text-left dark:text-gray-400">Last updated on <time datetime="{{ $datetime }}">{{ partial "utils/format-date" . }}</time></div>
{{- end -}}
{{ else }}
<div class="mt-16"></div>
{{ end }}

View File

@ -1,7 +1,9 @@
{{/* Article navigation on the footer of the article */}}
{{- $prev := .NextInSection -}}
{{- $next := .PrevInSection -}}
{{ $reversePagination := .Scratch.Get "reversePagination" | default false }}
{{- $prev := cond $reversePagination .PrevInSection .NextInSection -}}
{{- $next := cond $reversePagination .NextInSection .PrevInSection -}}
{{- if or $prev $next -}}
<div class="mb-8 flex items-center border-t pt-8 dark:border-neutral-800 contrast-more:border-neutral-400 dark:contrast-more:border-neutral-400 print:hidden">
{{- if $prev -}}