Excerpts and blog lists (mostly)

This commit is contained in:
Lewis Dale 2023-02-13 13:35:44 +00:00
parent 567d10b50f
commit 81bc038016
7 changed files with 35 additions and 3 deletions

View File

@ -5,5 +5,5 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.setDataDeepMerge(true);
eleventyConfig.setFrontMatterParsingOptions({ excerpt: true });
eleventyConfig.setFrontMatterParsingOptions({ excerpt: true, });
}

View File

@ -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))
}

View File

@ -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);
}

View File

@ -0,0 +1 @@
{{ excerpt }}

View File

@ -1,4 +1,23 @@
---
title: Blog
layout: base.njk
---
pagination:
data: collections.posts
size: 10
reverse: true
---
<main class="wrapper-lg stack-lg">
<h1>Blog posts</h1>
<ol class="stack-md">
{% for item in pagination.items %}
<li>
<h2><a href="{{ item.url }}">{{ item.data.title }}</a></h2>
<p>
{% set excerpt = item.page.excerpt %}
{% renderFile "./src/_includes/components/excerpt.md", item.page %}
</p>
</li>
{% endfor %}
</ol>
</main>

View File

@ -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

View File

@ -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