From 5c2942bc56ebb017179497699454c9cb75d7a97d Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 20 Oct 2024 09:19:14 -0700 Subject: [PATCH] Add a home/latest widget Add a shortcode and some styles for a two column, two row grid of latest posts. --- assets/css/099_home_latest.css | 24 ++++++++++++++++++++++++ layouts/shortcodes/home/latest.html | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 assets/css/099_home_latest.css create mode 100644 layouts/shortcodes/home/latest.html diff --git a/assets/css/099_home_latest.css b/assets/css/099_home_latest.css new file mode 100644 index 0000000..f4fbd13 --- /dev/null +++ b/assets/css/099_home_latest.css @@ -0,0 +1,24 @@ +.home-latest { + display: grid; + gap: 1ch; + grid-column: main-start / main-end; + grid-template-columns: 1fr 1fr; + grid-template-rows: min-content min-content; + grid-template-areas: + "blog1 photo" + "blog2 photo"; + + .home-latest__blog:nth-of-type(1) { + grid-area: blog1; + } + + .home-latest__blog:nth-of-type(2) { + grid-area: blog2; + } + + .home-latest__photo { + border-left: 2px dashed var(--gray6); + padding-inline-start: 1ch; + grid-area: photo; + } +} diff --git a/layouts/shortcodes/home/latest.html b/layouts/shortcodes/home/latest.html new file mode 100644 index 0000000..41defbf --- /dev/null +++ b/layouts/shortcodes/home/latest.html @@ -0,0 +1,19 @@ +{{- $blogSection := site.GetPage "blog" -}} +{{- $latestBlogPosts := $blogSection.Pages.ByDate.Reverse.Limit 2 -}} + +{{- $photosSection := site.GetPage "photos" -}} +{{- $latestPhotoPosts := $photosSection.Pages.ByDate.Reverse.Limit 1 -}} + +
+ {{ range $latestBlogPosts }} +
+ {{ .Render "page_summary" }} +
+ {{ end }} + {{ range $latestPhotoPosts }} +
+ {{ .Render "page_summary" }} +
+ {{ end }} +
+