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

feat: hide page modification date for talks and publications

Having both talk/pub. date and page modification date displayed may
cause confusion.

Close #891
George Cushen 6 жил өмнө
parent
commit
0a78ba6856

+ 3 - 2
exampleSite/config/_default/languages.toml

@@ -9,10 +9,11 @@
 # Uncomment the lines below to configure your website in a second language.
 #[zh]
 #  languageCode = "zh-Hans"
+#  contentDir = "content/zh"
 #  title = "Chinese website title..."
-#  [languages.zh.params]
+#  [zh.params]
 #    description = "Site description in Chinese..."
-#  [[languages.zh.menu.main]]
+#  [[zh.menu.main]]
 #    name = "Wo"
 #    url = "#about"
 #    weight = 1

+ 1 - 1
exampleSite/config/_default/params.toml

@@ -49,7 +49,7 @@ highlight = true
 # highlight_languages = ["r"]  # Add support for highlighting additional languages
 # highlight_style = "github"  # For supported styles, see https://cdnjs.com/libraries/highlight.js/
 
-# Enable native social sharing buttons?
+# Enable in-built social sharing buttons?
 sharing = true
 
 # Privacy pack

+ 1 - 0
exampleSite/content/privacy.md

@@ -3,6 +3,7 @@ title = "Privacy Policy"
 
 date = 2018-06-28T00:00:00
 draft = true
+share = false
 
 # [header]
 # image = ""

+ 14 - 12
layouts/_default/single.html

@@ -12,19 +12,21 @@
     </div>
 
     {{ partial "tags.html" . }}
-    {{ partial "page_author.html" . }}
 
-    {{ $related := .Site.RegularPages.Related . | first 5 }}
-    {{ with $related }}
-    <div class="article-widget">
-      <div class="hr-light"></div>
-      <h3>{{ i18n "related" }}</h3>
-      <ul>
-        {{ range . }}
-        <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
-        {{ end }}
-      </ul>
-    </div>
+    {{ if ne .Type "page" }}
+      {{ partial "page_author.html" . }}
+      {{ $related := .Site.RegularPages.Related . | first 5 }}
+      {{ with $related }}
+      <div class="article-widget">
+        <div class="hr-light"></div>
+        <h3>{{ i18n "related" }}</h3>
+        <ul>
+          {{ range . }}
+          <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+          {{ end }}
+        </ul>
+      </div>
+      {{ end }}
     {{ end }}
 
     {{ if .Site.Params.section_pager }}

+ 1 - 1
layouts/partials/header.html

@@ -16,7 +16,7 @@
   {{ $superuser_role := "" }}
   {{ range first 1 (where (where $.Site.Pages "Section" "author") "Params.superuser" true) }}
     {{ $superuser_name = .Params.name }}
-    {{ $superuser_username = .File.ContentBaseName }}
+    {{ $superuser_username = delimit (last 1 (split (substr .File.Dir 0 -1) "/")) "" }}
     {{ $superuser_role = .Params.role }}
   {{ end }}
   {{ $scr.Set "superuser_username" $superuser_username }}{{/* For access from page_author.html. */}}

+ 16 - 13
layouts/partials/page_metadata.html

@@ -1,10 +1,15 @@
 {{ $is_list := .is_list }}
 {{ $ := .content }}
+
+<meta content="{{ $.Params.Date }}" itemprop="datePublished">
+<meta content="{{ $.Params.LastMod }}" itemprop="dateModified">
+
 <div class="article-metadata">
 
   {{/* If `authors` is set and is not empty. */}}
   {{ if $.Params.authors }}
   {{ $authorLen := len $.Params.authors }}
+  {{ if gt $authorLen 0 }}
   <div>
     {{ range $k, $v := $.Params.authors -}}
     <span itemscope itemprop="author" itemtype="http://schema.org/Person">
@@ -17,24 +22,22 @@
     {{- if lt $k (sub $authorLen 1) -}}, {{ end }}
     {{ end }}
   </div>
-  {{ else }}
-  <span itemscope itemprop="author" itemtype="http://schema.org/Person">
-    <meta itemprop="name" content="{{ $.Site.Params.name }}">
-  </span>
+  {{ end }}
   {{ end }}
 
+  {{ if not (in (slice "talk" "page") $.Type) }}
   <span class="article-date">
-    {{ if ne $.Params.Lastmod $.Params.Date }}
-        {{ i18n "last_updated" }}
+    {{ $date := $.Lastmod.Format $.Site.Params.date_format }}
+    {{ if eq $.Type "publication" }}
+      {{ $date = $.Date.Format ($.Site.Params.publications.date_format | default "January, 2006") }}
+    {{ else }}
+      {{ if ne $.Params.Lastmod $.Params.Date }}
+          {{ i18n "last_updated" }}
+      {{ end }}
     {{ end }}
-    <meta content="{{ $.Params.Date }}" itemprop="datePublished">
-    <time datetime="{{ $.Params.LastMod }}" itemprop="dateModified">
-      {{ $.Lastmod.Format $.Site.Params.date_format }}
-    </time>
-  </span>
-  <span itemscope itemprop="publisher" itemtype="http://schema.org/Person">
-    <meta itemprop="name" content="{{ $.Site.Params.name }}">
+    <time>{{ $date }}</time>
   </span>
+  {{ end }}
 
   {{ if and (eq $.Type "post") (not (or (eq $.Site.Params.reading_time false) (eq $.Params.reading_time false))) }}
   <span class="middot-divider"></span>

+ 0 - 14
layouts/publication/single.html

@@ -45,20 +45,6 @@
     <div class="d-md-none space-below"></div>
     {{ end }}
 
-    <div class="row">
-      <div class="col-md-1"></div>
-      <div class="col-md-10">
-        <div class="row">
-          <div class="col-12 col-md-3 pub-row-heading">{{ i18n "date" }}</div>
-          <div class="col-12 col-md-9" itemprop="datePublished">
-            {{ .Date.Format ($.Site.Params.publications.date_format | default "January, 2006") }}
-          </div>
-        </div>
-      </div>
-      <div class="col-md-1"></div>
-    </div>
-    <div class="d-sm-none space-below"></div>
-
     <div class="space-below"></div>
 
     <div class="article-style">{{ .Content }}</div>