User docs: Improve blogging example

This commit is contained in:
Daniel Rudolf 2018-12-16 13:46:24 +01:00
parent 66dbf6b2c8
commit cbed65cfdf
No known key found for this signature in database
GPG key ID: A061F02CD8DE4538

View file

@ -140,16 +140,15 @@ If you want to use Pico as a blogging software, you probably want to do
something like the following:
1. Put all your blog articles in a separate `blog` folder in your `content`
directory. All these articles should have both a `Date` and `Template` meta
header, the latter with e.g. `blog-post` as value (see Step 2).
2. Create a new Twig template called `blog-post.twig` (this must match the
`Template` meta header from Step 1) in your theme directory. This template
probably isn't very different from your default `index.twig`, it specifies
how your article pages will look like.
3. Create a `blog.md` in your `content` folder and set its `Template` meta
header to e.g. `blog`. Also create a `blog.twig` in your theme directory.
This template will show a list of your articles, so you probably want to
do something like this:
directory. All these articles should have a `Date` meta header.
2. Create a `blog.md` or `blog/index.md` in your `content` directory. Add
`Template: blog-index` to the YAML header of this page. It will later show a
list of all your blog articles (see step 3).
3. Create the new Twig template `blog-index.twig` (the file name must match the
`Template` meta header from Step 2) in your theme directory. This template
probably isn't very different from your default `index.twig` (i.e. copy
`index.twig`), it will create a list of all your blog articles. Add the
following Twig snippet to `blog-index.twig` near `{{ content }}`:
```
{% for page in pages|sort_by("time")|reverse %}
{% if page.id starts with "blog/" and not page.hidden %}
@ -161,10 +160,6 @@ something like the following:
{% endif %}
{% endfor %}
```
4. Make sure to exclude blog articles from your page navigation. You can achieve
this by adding `{% if not (page.id starts with "blog/") %}...{% endif %}`
to the navigation loop (`{% for page in pages %}...{% endfor %}`) in your
theme's `index.twig`.
## Customization