From 1cfbe2d61d7f8beb9d7be5cc52994f83c32cd1dd Mon Sep 17 00:00:00 2001 From: Helen Chong <119173961+helenclx@users.noreply.github.com> Date: Wed, 17 Apr 2024 01:36:56 +0800 Subject: [PATCH] Add previous and next blog post section --- src/_includes/main/blogpost.njk | 26 ++++++++++++++++++++++++++ src/blog/posts/posts.11tydata.json | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/_includes/main/blogpost.njk diff --git a/src/_includes/main/blogpost.njk b/src/_includes/main/blogpost.njk new file mode 100644 index 00000000..f6acef4d --- /dev/null +++ b/src/_includes/main/blogpost.njk @@ -0,0 +1,26 @@ +--- +layout: main/article +--- + +{{ content | safe }} + +{%- if collections.posts %} + {%- set previousPost = collections.posts | getPreviousCollectionItem %} + {%- set nextPost = collections.posts | getNextCollectionItem %} + {%- if nextPost or previousPost %} + + {%- endif %} +{%- endif %} + + \ No newline at end of file diff --git a/src/blog/posts/posts.11tydata.json b/src/blog/posts/posts.11tydata.json index af01b67e..66ecb2fb 100644 --- a/src/blog/posts/posts.11tydata.json +++ b/src/blog/posts/posts.11tydata.json @@ -1,5 +1,5 @@ { - "layout": "main/article", + "layout": "main/blogpost", "tags": ["posts", "contents", "feed items"], "eleventyComputed": { "title": "{{ articleTitle }} | Blog"