Эх сурвалжийг харах

Display tags (if set) for all content types

Close #363
George Cushen 7 жил өмнө
parent
commit
6b7202c7bc

+ 4 - 0
archetypes/publication.md

@@ -37,6 +37,10 @@ selected = false
 #   E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`.
 projects = []
 
+# Tags (optional).
+#   Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags.
+tags = []
+
 # Links (optional).
 url_pdf = ""
 url_preprint = ""

+ 4 - 0
archetypes/talk.md

@@ -28,6 +28,10 @@ selected = false
 #   E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`.
 projects = []
 
+# Tags (optional).
+#   Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags.
+tags = []
+
 # Links (optional).
 url_pdf = ""
 url_slides = ""

+ 9 - 15
layouts/_default/single.html

@@ -6,23 +6,17 @@
   {{ partial "header_image.html" . }}
 
   <div class="article-container">
-    <h1 itemprop="name">{{ .Title }}</h1>
-    {{ partial "article_metadata" (dict "content" . "is_list" 0) }}
-    <div class="article-style" itemprop="articleBody">
-      {{ .Content }}
-    </div>
+    <div class="article-inner">
+      <h1 itemprop="name">{{ .Title }}</h1>
 
-    {{ if isset $.Params "tags" }}
-    {{ $tagsLen := len $.Params.tags }}
-    {{ if gt $tagsLen 0 }}
-    <div class="article-tags">
-      {{ range $k, $v := $.Params.tags }}
-      <a class="btn btn-primary btn-outline" href="{{ "/tags/" | relLangURL }}{{ . | urlize | lower }}">{{ . }}</a>
-      {{ end }}
-    </div>
-    {{ end }}
-    {{ end }}
+      {{ partial "article_metadata" (dict "content" . "is_list" 0) }}
+
+      <div class="article-style" itemprop="articleBody">
+        {{ .Content }}
+      </div>
 
+      {{ partial "tags.html" . }}
+    </div>
   </div>
 
 </article>

+ 10 - 0
layouts/partials/tags.html

@@ -0,0 +1,10 @@
+{{ if isset $.Params "tags" }}
+{{ $tagsLen := len $.Params.tags }}
+{{ if gt $tagsLen 0 }}
+<div class="article-tags">
+  {{ range $k, $v := $.Params.tags }}
+  <a class="btn btn-primary btn-outline" href="{{ "/tags/" | relLangURL }}{{ . | urlize | lower }}">{{ . }}</a>
+  {{ end }}
+</div>
+{{ end }}
+{{ end }}

+ 30 - 28
layouts/project/single.html

@@ -21,42 +21,44 @@
 
     <div class="article-style" itemprop="articleBody">
       {{ .Content }}
+    </div>
+
+    {{ partial "tags.html" . }}
 
-      {{ $page := . }}
-      {{ $project := .File.TranslationBaseName }}
-      {{ $project_path := printf "%s/%s/" .Section $project }}
+    {{ $page := . }}
+    {{ $project := .File.TranslationBaseName }}
+    {{ $project_path := printf "%s/%s/" .Section $project }}
 
-      {{ if (.Site.Params.projects.list_children | default true) }}
-        {{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }}
-        {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }}
-        {{ $pubs_len := len $items }}
-        {{ if ge $pubs_len 1 }}
-          <h2>{{ (i18n "publications") }}</h2>
-          {{ range $items }}
-            {{ if eq $page.Site.Params.projects.publication_format 1 }}
-              {{ partial "publication_li_detailed" . }}
-            {{ else if eq $page.Site.Params.projects.publication_format 2 }}
-              {{ partial "publication_li_apa" . }}
-            {{ else if eq $page.Site.Params.projects.publication_format 3 }}
-              {{ partial "publication_li_mla" . }}
-            {{ else }}
-              {{ partial "publication_li_simple" . }}
-            {{ end }}
+    {{ if (.Site.Params.projects.list_children | default true) }}
+      {{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }}
+      {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }}
+      {{ $pubs_len := len $items }}
+      {{ if ge $pubs_len 1 }}
+        <h2>{{ (i18n "publications") }}</h2>
+        {{ range $items }}
+          {{ if eq $page.Site.Params.projects.publication_format 1 }}
+            {{ partial "publication_li_detailed" . }}
+          {{ else if eq $page.Site.Params.projects.publication_format 2 }}
+            {{ partial "publication_li_apa" . }}
+          {{ else if eq $page.Site.Params.projects.publication_format 3 }}
+            {{ partial "publication_li_mla" . }}
+          {{ else }}
+            {{ partial "publication_li_simple" . }}
           {{ end }}
         {{ end }}
+      {{ end }}
 
-        {{ $items := where (where .Site.RegularPages "Type" "talk") ".Params.projects" "intersect" (slice $project) }}
-        {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }}
-        {{ $talks_len := len $items }}
-        {{ if ge $talks_len 1 }}
-          <h2>{{ (i18n "talks") }}</h2>
-          {{ range $items }}
-            {{ partial "talk_li_simple" . }}
-          {{ end }}
+      {{ $items := where (where .Site.RegularPages "Type" "talk") ".Params.projects" "intersect" (slice $project) }}
+      {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }}
+      {{ $talks_len := len $items }}
+      {{ if ge $talks_len 1 }}
+        <h2>{{ (i18n "talks") }}</h2>
+        {{ range $items }}
+          {{ partial "talk_li_simple" . }}
         {{ end }}
       {{ end }}
+    {{ end }}
 
-    </div>
   </div>
 </article>
 

+ 2 - 0
layouts/publication/single.html

@@ -91,6 +91,8 @@
 
     <div class="article-style">{{ .Content }}</div>
 
+    {{ partial "tags.html" . }}
+
   </div>
 </div>
 

+ 2 - 0
layouts/talk/single.html

@@ -102,6 +102,8 @@
       {{ .Content }}
     </div>
 
+    {{ partial "tags.html" . }}
+
   </div>
 </div>