diff --git a/_docs/creating-content.md b/_docs/creating-content.md index 7087251..29276fc 100644 --- a/_docs/creating-content.md +++ b/_docs/creating-content.md @@ -89,7 +89,7 @@ If you want to use Pico as a blogging software, you probably want to do somethin
  • 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: - {% raw %}
    {% for page in pages %}
    +        {% raw %}
    {% for page in pages|sort_by("time")|reverse %}
         {% if page.id starts with "blog/" %}
             <div class="post">
                 <h3><a href="{{ page.url }}">{{ page.title }}</a></h3>
    @@ -100,10 +100,7 @@ If you want to use Pico as a blogging software, you probably want to do somethin
     {% endfor %}
    {% endraw %}
  • - Let Pico sort pages by date by setting $config['pages_order_by'] = 'date'; in your config/config.php. To use a descending order (newest articles first), also add $config['pages_order'] = 'desc';. The former won't affect pages without a Date meta header, but the latter does. To use ascending order for your page navigation again, add Twigs reverse filter to the navigation loop ({% for page in pages|reverse %}...{% endfor %}}) in your themes index.twig. -
  • -
  • - Make sure to exclude the blog articles from your page navigation. You can achieve this by adding {% if not page starts with "blog/" %}...{% endif %} to the navigation loop. + Make sure to exclude the blog articles from your page navigation. You can achieve this by adding {% if not page starts with "blog/" %}...{% endif %} to the navigation loop ({% for page in pages %}...{% endfor %}}) in your themes index.twig.
  • diff --git a/_docs/customization.md b/_docs/customization.md index dfb8467..a90f1cb 100644 --- a/_docs/customization.md +++ b/_docs/customization.md @@ -60,6 +60,8 @@ Pages can be used like the following: {% endfor %} </ul>
    {% endraw %} +Additional to Twigs extensive list of filters, functions and tags, Pico also provides some useful additional filters to make theming easier. You can parse any Markdown string to HTML using the `markdown` filter. Arrays can be sorted by one of its keys or a arbitrary deep sub-key using the `sort_by` filter (e.g. `{% for page in pages|sort_by("meta:nav"|split(":")) %}...{% endfor %}` iterates through all pages, ordered by the `nav` meta header; please note the `"meta:nav"|split(":")` part of the example, which passes `['meta', 'nav']` to the filter describing a key path). You can return all values of a given key or key path of an array using the `map` filter (e.g. `{{ pages|map("title") }}` returns all page titles). + You can use different templates for different content files by specifying the `Template` meta header. Simply add e.g. `Template: blog-post` to a content file and Pico will use the `blog-post.twig` file in your theme folder to render the page. You don't have to create your own theme if Pico's default theme isn't sufficient for you, you can use one of the great themes third-party developers and designers created in the past. As with plugins, you can find themes in [our Wiki][WikiThemes].