Creation log
I'm neither extra proficient in English nor in coding and worst of all i have no knowledge of Javascript but this is a memo of things that didn't seems obvious to me to get this place working at the ultimate barebone form.
In the .eleventy.js file :
module.exports = function(eleventyConfig) {
// add my css file from the root folder
eleventyConfig.addPassthroughCopy("bundle.css");
// This line was to make sure my post.md weren't processed as Liquid, permitting this post here
eleventyConfig.setTemplateFormats(["md", "njk", "html"]);
return {
// Ok idk this prevent markdown from being processed?
markdownTemplateEngine: false,
dir: {
input: "./",
output: "_site",
layouts: "layouts",
includes: "includes"
}
};
};
The async showed in the doc is unnecessary (is it?), and the return part should be at the end of the function.
For the layout of a blog list in Nunjucks (file named "home.njk"):
---
pagination:
data: collections.post
size: 3
reverse: true
---
// [[PUT YOUR HTML HEADER HERE]]
// A Navbar from my includes folder providing links to single pages
{% include 'topbar.html' %}
// I put a welcome message in this index
{{ content | safe }}
<main>
<ul>
// listing 3 blog posts, both title and whole content
{% for post in pagination.items %}
<li><h3>{{ post.data.title | safe }}</h3></li>
{{ post.content | safe }}
{% endfor %}
</ul>
// Links to show back 3 older posts or 3 more recent
<p>{% if page.url != pagination.href.last %}<a href="{{ pagination.href.next }}">Prev Page</a>{% endif %} ---
{% if page.url != pagination.href.first %}<a href="{{ pagination.href.previous }}">Next Page</a>{% endif %}</p>
</main>
The data: collections.post will take all files tagged with "post". And then they will be listed 3 by 3 in reverse order on the blog part (the for loop).
Be aware that if you plan on switching from Liquid to Nunjucks by renaming your file because they seems identical, there actually are minor differences :
{% for post in pagination.items reversed %}
Should become :
{% for post in pagination.items | reverse %}
And if your ever simply rename like me, be aware that Eleventy will tell you an incorrect error line number, missing as many lines as you have metadata lines on top on your file.
Little anecdote: This was especially aggravating when i renamed since it told my for loop wasn't closed exactly where i had another for loop that was perfectly correct...
The said index page that use home.njk to show the post list, along with the " content" part with the welcome message :
---
layout: home.njk
title: unakt - hi
---
> Hi, I'm unakt - a living mess from France doing his best to sort things up.
And here is how the most basic post1.md should look like:
---
tags: post
title: The title of the post
---
Lorem Ipsum
sit dolor amen
And this is the most basic barebone elements needed for a blog... Now there's more things to look at, like the reverse order thing being a little janky at times, but in the grand scheme of things, this let me make some text based post,
as this one ;)
4th - I don't know why it doesn't list all poasts
Yeah, why the first post is ignored?
2nd -Maybe some cold take too?
Yeah maybe i'd be able to be considerate from time to time
Prev Page ---