From 81bc0380167cacb79d619e1a6777cb5ce0e2fa0f Mon Sep 17 00:00:00 2001 From: Lewis Dale Date: Mon, 13 Feb 2023 13:35:44 +0000 Subject: [PATCH] Excerpts and blog lists (mostly) --- config/files/index.js | 2 +- config/filters/index.js | 2 ++ config/plugins/index.js | 2 ++ src/_includes/components/excerpt.md | 1 + src/blog/index.html | 21 ++++++++++++++++++++- src/blog/posts/first-post.md | 7 +++++++ src/now.md | 3 ++- 7 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/_includes/components/excerpt.md diff --git a/config/files/index.js b/config/files/index.js index 9ca428b..91f6da0 100644 --- a/config/files/index.js +++ b/config/files/index.js @@ -5,5 +5,5 @@ module.exports = function(eleventyConfig) { eleventyConfig.addPassthroughCopy("src/assets"); eleventyConfig.setDataDeepMerge(true); - eleventyConfig.setFrontMatterParsingOptions({ excerpt: true }); + eleventyConfig.setFrontMatterParsingOptions({ excerpt: true, }); } \ No newline at end of file diff --git a/config/filters/index.js b/config/filters/index.js index ba09970..b10d36c 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -4,4 +4,6 @@ const arrayFilters = require('./arrays'); module.exports = function(eleventyConfig) { eleventyConfig.addPlugin(dateFilters); eleventyConfig.addPlugin(arrayFilters); + + eleventyConfig.addFilter('keys', obj => Object.keys(obj)) } \ No newline at end of file diff --git a/config/plugins/index.js b/config/plugins/index.js index 1e14cde..fdf8fc9 100644 --- a/config/plugins/index.js +++ b/config/plugins/index.js @@ -1,3 +1,4 @@ +const { EleventyRenderPlugin } = require("@11ty/eleventy"); const markdownPlugin = require('./markdown'); const rss = require('@11ty/eleventy-plugin-rss'); const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); @@ -8,4 +9,5 @@ module.exports = function(eleventyConfig) { eleventyConfig.addPlugin(rss); eleventyConfig.addPlugin(markdownPlugin); eleventyConfig.addPlugin(imagePlugin); + eleventyConfig.addPlugin(EleventyRenderPlugin); } \ No newline at end of file diff --git a/src/_includes/components/excerpt.md b/src/_includes/components/excerpt.md new file mode 100644 index 0000000..b8e151a --- /dev/null +++ b/src/_includes/components/excerpt.md @@ -0,0 +1 @@ +{{ excerpt }} \ No newline at end of file diff --git a/src/blog/index.html b/src/blog/index.html index 684e417..532e904 100644 --- a/src/blog/index.html +++ b/src/blog/index.html @@ -1,4 +1,23 @@ --- title: Blog layout: base.njk ---- \ No newline at end of file +pagination: + data: collections.posts + size: 10 + reverse: true +--- +
+

Blog posts

+ +
    + {% for item in pagination.items %} +
  1. +

    {{ item.data.title }}

    +

    + {% set excerpt = item.page.excerpt %} + {% renderFile "./src/_includes/components/excerpt.md", item.page %} +

    +
  2. + {% endfor %} +
+
\ No newline at end of file diff --git a/src/blog/posts/first-post.md b/src/blog/posts/first-post.md index d8ae263..3602ef8 100644 --- a/src/blog/posts/first-post.md +++ b/src/blog/posts/first-post.md @@ -2,6 +2,13 @@ title: My first post --- +This is an excerpt, written at the start of the post + +* Wait, does it not render markdown? +* Let's find out + +--- + Something something something ## Something else diff --git a/src/now.md b/src/now.md index eab14e3..14154c1 100644 --- a/src/now.md +++ b/src/now.md @@ -5,7 +5,7 @@ layout: page.njk ## What I'm reading -* :book: City of Last Chances by Adrian Tchaikovsky +* :book: The Player of Games by Iain M. Banks ## What I'm watching @@ -16,3 +16,4 @@ layout: page.njk * :bicycle: Preparing for a 100km charity cycle * :people-roof: Spending time with my family * :computer: Working on my ZX Basic interpreter +* :gamepad: Playing The Outer Worlds on Nintendo Switch