Add article pagination links and display params

pull/2/head
James Panther 2021-08-14 14:44:34 +10:00
parent 074b1ff11d
commit c24b8ab2e1
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
9 changed files with 114 additions and 40 deletions

View File

@ -1,3 +1,17 @@
# -- Theme Options --
# These options control how the theme functions and allow you to
# customise the display of your website.
[article]
showDate = true
dateFormat = "2 January 2006"
showReadingTime = true
showAuthor = true
showPagination = true
[taxonomy]
showTermCount = true
# -- Site Verification -- # -- Site Verification --
# Provide the verification strings for the providers below and the # Provide the verification strings for the providers below and the
# corresponding meta tags will be added to the site <head>. # corresponding meta tags will be added to the site <head>.

View File

@ -3,7 +3,7 @@
<header> <header>
<h1 class="mt-0 text-4xl font-extrabold">{{ .Title }}</h1> <h1 class="mt-0 text-4xl font-extrabold">{{ .Title }}</h1>
<div class="mt-8 mb-12 text-base text-gray-400 dark:text-gray-500"> <div class="mt-8 mb-12 text-base text-gray-400 dark:text-gray-500">
{{ partial "meta.html" . }} {{ partial "article-meta.html" . }}
</div> </div>
</header> </header>
<section class="prose dark:prose-light"> <section class="prose dark:prose-light">
@ -11,6 +11,7 @@
</section> </section>
<footer> <footer>
{{ partialCached "author.html" . }} {{ partialCached "author.html" . }}
{{ partial "article-pagination.html" . }}
</footer> </footer>
{{/* Comments */}} {{/* Comments */}}
{{ if templates.Exists "partials/comments.html" }} {{ if templates.Exists "partials/comments.html" }}

View File

@ -7,10 +7,12 @@
<a class="text-xl font-medium hover:underline" href="{{ .Page.Permalink }}" <a class="text-xl font-medium hover:underline" href="{{ .Page.Permalink }}"
>{{ .Page.Title }}</a >{{ .Page.Title }}</a
> >
<span class="text-base text-gray-400"> {{ if $.Site.Params.taxonomy.showTermCount | default true }}
<span class="px-1">&middot;</span> <span class="text-base text-gray-400">
{{ .Count }} <span class="px-1">&middot;</span>
</span> {{ .Count }}
</span>
{{ end }}
</h2> </h2>
</article> </article>
{{ end }} {{ end }}

View File

@ -18,6 +18,6 @@
{{ end }} {{ end }}
</h3> </h3>
<div class="text-sm text-gray-400 dark:text-gray-500"> <div class="text-sm text-gray-400 dark:text-gray-500">
{{ partial "meta.html" . }} {{ partial "article-meta.html" . }}
</div> </div>
</article> </article>

View File

@ -0,0 +1,18 @@
{{ if .Site.Params.article.showDate | default true }}
<time datetime="{{ .Date }}">
{{ .Date.Format .Site.Params.article.dateFormat | default "2 January 2006" }}
</time>
{{ end }}
{{ if and
(.Site.Params.article.showDate | default true)
(.Site.Params.article.showReadingTime | default true)
(ne .ReadingTime 0)
}}
<span class="px-1">&middot;</span>
{{ end }}
{{ if and (.Site.Params.article.showReadingTime | default true) (ne .ReadingTime 0) }}
<span title="Reading time">
{{ .ReadingTime }}
min{{ if gt .ReadingTime 1 }}s{{ end }}
</span>
{{ end }}

View File

@ -0,0 +1,45 @@
{{ if .Site.Params.article.showPagination | default true }}
{{ if or .NextInSection .PrevInSection }}
<div class="pt-8">
<hr class="border-gray-300 border-dotted dark:border-gray-600" />
<div class="flex justify-between pt-3">
<span>
{{ if .NextInSection }}
<a class="flex" href="{{ .NextInSection.Permalink }}">
<span class="mr-3"></span>
<span class="flex flex-col">
<span class="button__text">{{ .NextInSection.Title }}</span>
{{ if .Site.Params.article.showDate | default true }}
<time
class="-mt-1 text-xs text-gray-400 dark:text-gray-500"
datetime="{{ .Date }}"
>
{{ .Date.Format .Site.Params.article.dateFormat | default "2 January 2006" }}
</time>
{{ end }}
</span>
</a>
{{ end }}
</span>
<span>
{{ if .PrevInSection }}
<a class="flex text-right" href="{{ .PrevInSection.Permalink }}">
<span class="flex flex-col">
<span>{{ .PrevInSection.Title }}</span>
{{ if .Site.Params.article.showDate | default true }}
<time
class="-mt-1 text-xs text-gray-400 dark:text-gray-500"
datetime="{{ .Date }}"
>
{{ .Date.Format .Site.Params.article.dateFormat | default "2 January 2006" }}
</time>
{{ end }}
</span>
<span class="ml-3"></span>
</a>
{{ end }}
</span>
</div>
</div>
{{ end }}
{{ end }}

View File

@ -1,28 +1,30 @@
<div class="flex items-center pt-8"> {{ if .Site.Params.article.showAuthor | default true }}
{{ with .Site.Author.image }} <div class="flex items-center pt-8">
<img class="w-24 h-24 !mt-0 !mb-0 mr-4 rounded-full" src="{{ . }}" /> {{ with .Site.Author.image }}
{{ end }} <img class="w-24 h-24 !mt-0 !mb-0 mr-4 rounded-full" src="{{ . }}" />
<div>
{{ with .Site.Author.name }}
<div class="font-semibold leading-6 text-gray-800 dark:text-gray-300">
{{ . }}
</div>
{{ end }} {{ end }}
{{ with .Site.Author.links }} <div>
<div class="flex flex-wrap text-lg text-gray-400 dark:text-gray-500"> {{ with .Site.Author.name }}
{{ range $links := . }} <div class="font-semibold leading-6 text-gray-800 dark:text-gray-300">
{{ range $name, $url := $links }} {{ . }}
<a </div>
class="mr-2 hover:text-primary-700 dark:hover:text-primary-400" {{ end }}
href="{{ $url }}" {{ with .Site.Author.links }}
target="_blank" <div class="flex flex-wrap text-lg text-gray-400 dark:text-gray-500">
alt="{{ $name | title }}" {{ range $links := . }}
rel="me" {{ range $name, $url := $links }}
>{{ partial "icon.html" $name }}</a <a
> class="mr-2 hover:text-primary-700 dark:hover:text-primary-400"
href="{{ $url }}"
target="_blank"
alt="{{ $name | title }}"
rel="me"
>{{ partial "icon.html" $name }}</a
>
{{ end }}
{{ end }} {{ end }}
{{ end }} </div>
</div> {{ end }}
{{ end }} </div>
</div> </div>
</div> {{ end }}

View File

@ -1,8 +0,0 @@
<time datetime="{{ .Date }}">{{ .Date.Format "2 January 2006" }}</time>
{{ if ne .ReadingTime 0 }}
<span class="px-1">&middot;</span>
<span title="Reading time">
{{ .ReadingTime }}
min{{ if gt .ReadingTime 1 }}s{{ end }}
</span>
{{ end }}

File diff suppressed because one or more lines are too long