Added excerpts

- added configuration for excerpts
- updated example articles with excerpts
- added excerpt to render in the article previews
This commit is contained in:
Claudia Reynders 2022-04-30 18:25:07 +02:00
parent 5730117055
commit 42fddb5416
5 changed files with 14 additions and 3 deletions

View File

@ -23,6 +23,13 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addCollection('categoryList', require('./src/_11ty/getCategoryList')) eleventyConfig.addCollection('categoryList', require('./src/_11ty/getCategoryList'))
eleventyConfig.addCollection('categories', require('./src/_11ty/createCategories')) eleventyConfig.addCollection('categories', require('./src/_11ty/createCategories'))
eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
excerpt_separator: "<!-- excerpt -->",
excerpt_alias: 'excerpt'
})
return { return {
dir: { dir: {
input: 'src', input: 'src',

View File

@ -3,6 +3,7 @@
<li class="article__item"> <li class="article__item">
<article class="article__preview"> <article class="article__preview">
<h2><a href="{{ article.url | url }}">{{ article.data.title }}</a></h2> <h2><a href="{{ article.url | url }}">{{ article.data.title }}</a></h2>
<p>{{ article.data.excerpt }}</p>
<small> <small>
<time>{{ article.data.date | readableDate }}</time> <time>{{ article.data.date | readableDate }}</time>
<a class="category" href="/blog/{{ article.data.category }}">{{ article.data.category }}</a> <a class="category" href="/blog/{{ article.data.category }}">{{ article.data.category }}</a>

View File

@ -6,6 +6,7 @@ category: "cat1"
--- ---
Having landed on this Eleventy starter, you probably are no stranger to Eleventy. But if you are, you should definitely check out its benefits. Getting started with Eleventy is quick and easy. Having landed on this Eleventy starter, you probably are no stranger to Eleventy. But if you are, you should definitely check out its benefits. Getting started with Eleventy is quick and easy.
<!-- excerpt -->
{% image "https://images.unsplash.com/photo-1555066931-4365d14bab8c", "A laptop with some lines of code on the screen", null, [300, 600] %} {% image "https://images.unsplash.com/photo-1555066931-4365d14bab8c", "A laptop with some lines of code on the screen", "image", [300, 600] %}

View File

@ -6,3 +6,4 @@ category: "cat2"
--- ---
With Eleventy you can gradually expand your website and its complexity level. With Eleventy you can gradually expand your website and its complexity level.
<!-- excerpt -->

View File

@ -6,3 +6,4 @@ category: "cat1"
--- ---
There are many different static site generators out there, but after having used middleman for such a long time, it just made sense to switch to Eleventy. I needed something simple that gave lots of control over how I build my website. There are many different static site generators out there, but after having used middleman for such a long time, it just made sense to switch to Eleventy. I needed something simple that gave lots of control over how I build my website.
<!-- excerpt -->