From c82d5602bb977453b878b3be0bb9f6431dabe317 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Fri, 29 Apr 2022 19:09:26 -0500 Subject: [PATCH] Add "Latest Posts" section to homepage --- exampleSite/config.yaml | 7 +++++++ i18n/en.yaml | 3 +++ layouts/_default/baseof.html | 2 +- layouts/index.html | 27 +++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 924a8a7..987cbac 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -31,6 +31,13 @@ params: # gitFileURL: https://github.com/BBaoVanC/bobatheme/blob/master # gitFileIcon: github-circle + # display a "Latest Posts" section on the homepage below its content + homepageLatestPosts: true + + # footer: >- + # Some example text for the footer. + + # see https://gohugo.io/about/hugo-and-gdpr/#all-privacy-settings # you probably want to keep this default privacy: diff --git a/i18n/en.yaml b/i18n/en.yaml index f117772..d967df9 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -8,6 +8,9 @@ table_of_contents: browser_no_video_support: other: "Your browser does not support video." +latest_posts: + other: "Latest Posts" + # Meta items long_date: diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 881c11c..d66471f 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -16,7 +16,7 @@
{{ block "main" . }} - {{ .Content }} + THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it) {{ end }}
diff --git a/layouts/index.html b/layouts/index.html index e4e4a83..ce2e79f 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,2 +1,29 @@ {{ define "main" }} + {{ with .Content }} + {{ . }} + {{ end }} + + {{ if .Site.Params.homepageLatestPosts }} +
+

+ {{ i18n "latest_posts" }} + {{ partial "rss-link.html" . }} +

+ + {{ with (.Paginate .Site.RegularPages).Pages }} +
+ +
+ {{ else }} +
+ {{ i18n "no_posts" }} +
+ {{ end }} + + {{ partial "pagination.html" . }} + {{ end }} {{ end }}