Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/yihui/hugo-xmag.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYihui Xie <xie@yihui.name>2017-07-20 01:11:19 +0300
committerYihui Xie <xie@yihui.name>2017-07-20 01:11:19 +0300
commit412c0591715610b9ce78509a127de31526d83764 (patch)
tree0f8e5c9f3b9824fc53548be6d2d4742248e26666 /layouts
parentc8d28c33b69730824a1d40bd9a637197613bd033 (diff)
support multiple authors for a single post https://github.com/cosname/cosx.org/issues/637
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/list.html2
-rw-r--r--layouts/_default/single.html4
-rw-r--r--layouts/partials/author.html19
-rw-r--r--layouts/partials/author_names.html1
4 files changed, 21 insertions, 5 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 4016581..752be70 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -16,7 +16,7 @@
</div>
<h1><a href="{{ .URL }}">{{ .Title }}</a></h1>
<div class="date-author">
- {{ with .Params.author }}<span class="author">{{ . }}</span> / {{ end }}
+ {{ if .Params.author }}<span class="author">{{ partial "author_names.html" . }}</span> / {{ end }}
<span class="date">{{ .Date.Format "2006-01-02" }}</span>
</div>
<div class="summary">
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 62f1c83..173ec3b 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -11,8 +11,8 @@
<h1><span class="title">{{ .Title }}</span></h1>
- {{ with .Params.author }}
- <h3 class="author">{{ . }}</h3>
+ {{ if .Params.author }}
+ <h3 class="author">{{ partial "author_names.html" . }}</h3>
{{ end }}
{{ with .Params.tags }}
diff --git a/layouts/partials/author.html b/layouts/partials/author.html
index c5ed53d..c4977ab 100644
--- a/layouts/partials/author.html
+++ b/layouts/partials/author.html
@@ -1,10 +1,25 @@
{{ with .Params.author }}
+{{ if eq (substr (jsonify .) 0 1) "["}}
+{{ $.Scratch.Set "page_author" .}}
+{{ else }}
+{{ $.Scratch.Set "page_author" (slice .) }}
+{{ end }}
+
+{{ $.Scratch.Set "author_info" slice }}
{{ if $.Site.Data.authors }}
+{{ range $.Scratch.Get "page_author" }}
{{ with (index $.Site.Data.authors .) }}
+{{ $.Scratch.Add "author_info" . }}
+{{ end }}
+{{ end }}
+{{ end }}
+{{ if $.Scratch.Get "author_info" }}
<section class="article-meta article-footer">
<h3>{{ default "About the Author" $.Site.Params.text.about_author }}</h3>
- <p>{{ . | markdownify }}</p>
+ {{ range $.Scratch.Get "author_info" }}
+ <p>{{ . | markdownify }}</p>
+ {{ end }}
</section>
{{ end }}
-{{ end }}
+
{{ end }}
diff --git a/layouts/partials/author_names.html b/layouts/partials/author_names.html
new file mode 100644
index 0000000..bbbc978
--- /dev/null
+++ b/layouts/partials/author_names.html
@@ -0,0 +1 @@
+{{ replace ((jsonify .Params.author) | replaceRE "[\\[\"\\]]" "") "," (default ", " $.Site.Params.text.author_delimiter) | safeHTML }}