Add edit links on article pages

This commit is contained in:
James Panther
2021-08-21 11:42:40 +10:00
parent 46a7031a3a
commit d022bc8df7
16 changed files with 96 additions and 40 deletions
+1 -5
View File
@@ -8,10 +8,7 @@
{{ .Title | emojify }}
</h1>
<div class="mt-8 mb-12 text-base text-neutral-400 dark:text-neutral-500">
{{ partial "article-meta.html" . }}
{{ if and .Draft .Site.Params.article.showDraftLabel }}
<span class="pl-2">{{ partial "badge.html" (i18n "article.draft" | emojify) }}</span>
{{ end }}
{{ partial "article-meta.html" (dict "context" . "scope" "single") }}
</div>
</header>
<section class="prose dark:prose-light">
@@ -22,7 +19,6 @@
{{ partial "sharing-links.html" . }}
{{ partial "article-pagination.html" . }}
</footer>
{{/* Comments */}}
{{ if templates.Exists "partials/comments.html" }}
{{ partial "comments.html" . }}
{{ end }}
+4 -2
View File
@@ -1,5 +1,5 @@
<article>
<h3 class="mt-6 text-xl font-semibold">
<h3 class="flex items-center mt-6 text-xl font-semibold">
{{ if isset .Params "externalUrl" }}
<a
class="hover:underline hover:underline-primary-500 hover:underline-offset-small text-neutral-800 dark:text-neutral"
@@ -22,7 +22,9 @@
>
{{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }}
{{ partial "badge.html" "Draft" }}
<div class="ml-2">
{{ partial "badge.html" "Draft" }}
</div>
{{ end }}
{{ if templates.Exists "partials/extend-article-link.html" }}
{{ partial "extend-article-link.html" . }}
+37 -15
View File
@@ -1,17 +1,39 @@
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
<time datetime="{{ .Date }}">
{{ .Date.Format .Site.Params.article.dateFormat | default "2 January 2006" }}
</time>
{{/* Determine the correct context and scope */}}
{{/* This allows for different logic depending on where the partial is called */}}
{{ $context := . }}
{{ $scope := default nil }}
{{ if (reflect.IsMap . ) }}
{{ $context = .context }}
{{ $scope = cond (not .scope) nil .scope }}
{{ end }}
{{ if and
(.Params.showDate | default (.Site.Params.article.showDate | default true))
(.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true))
(ne .ReadingTime 0)
}}
<span class="px-1 text-primary-500">&middot;</span>
{{ end }}
{{ if and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0) }}
<span title="{{ i18n "article.reading_time_title" }}">
{{ i18n "article.reading_time" .ReadingTime | emojify }}
</span>
{{ with $context }}
{{ $meta := newScratch }}
{{/* Gather partials for this context */}}
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ $meta.Add "partials" (slice (partial "meta/date.html" .)) }}
{{ end }}
{{ if and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0) }}
{{ $meta.Add "partials" (slice (partial "meta/reading-time.html" .)) }}
{{ end }}
{{ if and (eq $scope "single") (.Params.showEdit | default (.Site.Params.article.showEdit | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/edit.html" .)) }}
{{ end }}
<div class="flex flex-row items-center">
{{/* Output partials */}}
{{ with ($meta.Get "partials") }}
{{ delimit . "<span class=\"px-2 text-primary-500\">&middot;</span>" }}
{{ end }}
{{/* Output draft label */}}
{{ if and (eq $scope "single") (and .Draft .Site.Params.article.showDraftLabel) }}
<span class="pl-2">{{ partial "badge.html" (i18n "article.draft" | emojify) }}</span>
{{ end }}
</div>
{{ end }}
+10 -16
View File
@@ -9,14 +9,11 @@
<span class="mr-3 article-pagination-direction">&larr;</span>
<span class="flex flex-col">
<span class="article-pagination-title">{{ .NextInSection.Title }}</span>
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
<time
class="-mt-1 text-xs text-neutral-400 dark:text-neutral-500"
datetime="{{ .Date }}"
>
{{ .Date.Format .Site.Params.article.dateFormat | default "2 January 2006" }}
</time>
{{ end }}
<span class="-mt-1 text-xs text-neutral-400 dark:text-neutral-500">
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ partial "meta/date.html" . }}
{{ end }}
</span>
</span>
</a>
{{ end }}
@@ -26,14 +23,11 @@
<a class="flex text-right" href="{{ .PrevInSection.Permalink }}">
<span class="flex flex-col">
<span class="article-pagination-title">{{ .PrevInSection.Title }}</span>
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
<time
class="-mt-1 text-xs text-neutral-400 dark:text-neutral-500"
datetime="{{ .Date }}"
>
{{ .Date.Format .Site.Params.article.dateFormat | default "2 January 2006" }}
</time>
{{ end }}
<span class="-mt-1 text-xs text-neutral-400 dark:text-neutral-500">
{{ if .Params.showDate | default (.Site.Params.article.showDate | default true) }}
{{ partial "meta/date.html" . }}
{{ end }}
</span>
</span>
<span class="ml-3 article-pagination-direction">&rarr;</span>
</a>
+1 -1
View File
@@ -1,5 +1,5 @@
<span
class="ml-1 px-1 py-[1px] text-xs font-normal border rounded-md text-primary-700 dark:text-primary-400 border-primary-400 dark:border-primary-600 inline-block align-middle mb-1"
class="ml-1 px-1 py-[1px] text-xs font-normal border rounded-md text-primary-700 dark:text-primary-400 border-primary-400 dark:border-primary-600 flex"
>
{{ . }}
</span>
+4
View File
@@ -0,0 +1,4 @@
<time datetime="{{ .Date }}">
{{- .Date.Format .Site.Params.article.dateFormat | default "2 January 2006" -}}
</time>
{{- /* Trim EOF */ -}}
+19
View File
@@ -0,0 +1,19 @@
{{ $url := .Params.editURL | default (.Site.Params.article.editURL | default "#") }}
{{ $slash := "" }}
{{ if .Params.editAppendPath | default ( .Site.Params.article.editAppendPath | default false ) }}
{{ if ne (substr $url -1 1) "/" }}
{{ $slash = "/" }}
{{ end }}
{{ $url = printf "%s%s%s" $url $slash (path.Join .File.Path) }}
{{ end }}
<span class="mb-[2px]">
<a
href="{{ $url }}"
class="text-lg hover:text-primary-500"
rel="noopener noreferrer"
target="_blank"
title="{{ i18n "article.edit_title" }}"
>{{ partial "icon.html" "edit" }}</a
>
</span>
{{- /* Trim EOF */ -}}
+4
View File
@@ -0,0 +1,4 @@
<span title="{{ i18n "article.reading_time_title" }}">
{{- i18n "article.reading_time" .ReadingTime | emojify -}}
</span>
{{- /* Trim EOF */ -}}