From ec0bc45e5d7824b5a04daf7f34c221cc66d8eff9 Mon Sep 17 00:00:00 2001
From: Xiang Li <78754416+xiangli2pro@users.noreply.github.com>
Date: Sun, 21 Mar 2021 10:47:33 +0000
Subject: [PATCH] Added readmore links in index.html (#160)

---
 exampleSite/config.toml |    3 +
 i18n/zh-cn.toml         |    3 +
 i18n/zh-tw.toml         |    5 ++
 i18n/dk.toml            |    5 ++
 i18n/es.toml            |    5 ++
 i18n/fi.toml            |    5 ++
 README.md               |    7 +++
 i18n/de.toml            |    5 ++
 i18n/fa.toml            |    5 ++
 i18n/pt-br.toml         |    3 +
 i18n/en.toml            |    5 ++
 layouts/index.html      |   16 ++++++--
 i18n/it.toml            |    5 ++
 i18n/fr.toml            |    5 ++
 14 files changed, 64 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index 061987a..a10b27a 100644
--- a/README.md
+++ b/README.md
@@ -150,6 +150,13 @@
 listDateFormat = "Jan 2"
 ```
 
+### Read-more Links
+You can enable read-more links for truncated posts by setting the `readMore = true`. The length of the preview is controlled by Hugo's `summarylength`. Read-more links are disabled by default.
+```toml
+[params]
+  readMore = true
+```
+
 ### Have a static page as a home page
 If you prefer having a static page as your home page rather than a listing of the latest posts, then make sure you leave the `mainSections` parameter blank:
 ```toml
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 7981a0b..e9b6f45 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -42,6 +42,9 @@
 # singleDateFormat = "Mon, Jan 2, 2006"
 # Commento Comments
 # CommentoURL = "https://commento.example.com/js/commento.js"
+# Read More links for truncated summaries
+# readMore = true
+
 
 [params.simpleAnalytics]
 # enable = true
diff --git a/i18n/de.toml b/i18n/de.toml
index 0ed8625..b069d59 100644
--- a/i18n/de.toml
+++ b/i18n/de.toml
@@ -21,4 +21,7 @@
 other = "Kommentare"
 
 [send]
-other = "Senden"
\ No newline at end of file
+other = "Senden"
+
+[read_more]
+other = "weiterlesen"
\ No newline at end of file
diff --git a/i18n/dk.toml b/i18n/dk.toml
index 1ed7e77..2ae6701 100644
--- a/i18n/dk.toml
+++ b/i18n/dk.toml
@@ -21,4 +21,7 @@
 other = "kommentar"
 
 [send]
-other = "Sende"
\ No newline at end of file
+other = "Sende"
+
+[read_more]
+other = "Læs mere"
\ No newline at end of file
diff --git a/i18n/en.toml b/i18n/en.toml
index db43452..17bbe87 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -21,4 +21,7 @@
 other = "comments"
 
 [send]
-other = "Send"
\ No newline at end of file
+other = "Send"
+
+[read_more]
+other = "Read more"
\ No newline at end of file
diff --git a/i18n/es.toml b/i18n/es.toml
index a95542a..89a57e3 100644
--- a/i18n/es.toml
+++ b/i18n/es.toml
@@ -21,4 +21,7 @@
 other = "comentarios"
 
 [send]
-other = "Enviar"
\ No newline at end of file
+other = "Enviar"
+
+[read_more]
+other = "Leer más"
\ No newline at end of file
diff --git a/i18n/fa.toml b/i18n/fa.toml
index 2911b2c..c9172e3 100644
--- a/i18n/fa.toml
+++ b/i18n/fa.toml
@@ -21,4 +21,7 @@
 other = "نظرات"
 
 [send]
-other = "ارسال"
\ No newline at end of file
+other = "ارسال"
+
+[read_more]
+other = "ادامه خواندن"
\ No newline at end of file
diff --git a/i18n/fi.toml b/i18n/fi.toml
index 622de2c..3596b24 100644
--- a/i18n/fi.toml
+++ b/i18n/fi.toml
@@ -21,4 +21,7 @@
 other = "kommentit"
 
 [send]
-other = "Lähetä"
\ No newline at end of file
+other = "Lähetä"
+
+[read_more]
+other = "Jatka lukemista"
\ No newline at end of file
diff --git a/i18n/fr.toml b/i18n/fr.toml
index b97fd5a..4386b2c 100644
--- a/i18n/fr.toml
+++ b/i18n/fr.toml
@@ -21,4 +21,7 @@
 other = "commentaire"
 
 [send]
-other = "Envoyer"
\ No newline at end of file
+other = "Envoyer"
+
+[read_more]
+other = "continuer la lecture"
\ No newline at end of file
diff --git a/i18n/it.toml b/i18n/it.toml
index 9f6020c..31e3aca 100644
--- a/i18n/it.toml
+++ b/i18n/it.toml
@@ -21,4 +21,7 @@
 other = "commenti"
 
 [send]
-other = "Spedire"
\ No newline at end of file
+other = "Spedire"
+
+[read_more]
+other = "Continua a leggere"
\ No newline at end of file
diff --git a/i18n/pt-br.toml b/i18n/pt-br.toml
index 2456fa9..52f744f 100644
--- a/i18n/pt-br.toml
+++ b/i18n/pt-br.toml
@@ -22,3 +22,6 @@
 
 [send]
 other = "Enviar"
+
+[read_more]
+other = "continue lendo"
\ No newline at end of file
diff --git a/i18n/zh-cn.toml b/i18n/zh-cn.toml
index 62c1293..342f231 100755
--- a/i18n/zh-cn.toml
+++ b/i18n/zh-cn.toml
@@ -22,3 +22,6 @@
 
 [send]
 other = "发送"
+
+[read_more]
+other = "继续阅读"
\ No newline at end of file
diff --git a/i18n/zh-tw.toml b/i18n/zh-tw.toml
index 87e7e69..c758abc 100644
--- a/i18n/zh-tw.toml
+++ b/i18n/zh-tw.toml
@@ -21,4 +21,7 @@
 other = "註解"
 
 [send]
-other = "發送"
\ No newline at end of file
+other = "發送"
+
+[read_more]
+other = "繼續閱讀"
\ No newline at end of file
diff --git a/layouts/index.html b/layouts/index.html
index ecd78ae..4978361 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -26,15 +26,23 @@
                 </h3>
             </div>
             <div class="post-content">
-                <div class="p_part"><p>{{ if .Site.Params.fullPostContent }}{{ .Content }}{{ else }}{{ .Summary }}{{ end }}</p></div>
+                <div class="p_part">
+                    <p>{{ if .Site.Params.fullPostContent }}{{ .Content }}{{ else }}{{ .Summary }}{{ end }}</p>
+                    <!-- add read more -->
+                    {{- if and (.Truncated) (.Site.Params.readMore) -}}
+                        <a href='{{ .RelPermalink }}' class="read_more">{{ i18n "read_more" }}</a>
+                    {{- end -}}
+                </div>
             </div>
+
+            <!--  -->
             <div class="post-footer">
                 <div class="meta">
                     <div class="info">
                         <em class="fas fa-calendar-day"></em>
-                            <span class="date">{{ if isset .Site.Params "indexdateformat" }} 
-                                                 {{ .Date.Format .Site.Params.indexDateFormat }} 
-                                             {{ else }} {{.Date.Format "Mon, Jan 2, 2006"}} 
+                            <span class="date">{{ if isset .Site.Params "indexdateformat" }}
+                                                 {{ .Date.Format .Site.Params.indexDateFormat }}
+                                             {{ else }} {{.Date.Format "Mon, Jan 2, 2006"}}
                                              {{ end }}</span>
                         {{ with .Page.Params.Categories }}{{ partial "taxonomy/categories.html" . }}{{ end }}
                         {{ with .Page.Params.Tags }}{{ partial "taxonomy/tags.html" . }}{{ end }}

--
Gitblit v1.10.0