Archive more directory under content

I use tabi theme, how to archived more than one directory under content, content/blog, content/doc_1, content/note. and etc.

I just implemented this in the theme (PR 249).

For others who might want to do the same, here’s how I did it:

  1. Check if the section_path is a string. If so, turn it into an array.
  2. Iterate over the array collecting all pages (important: use set_global).
  3. Group the posts and display them.

In code (takes into account multilingual setups):

{%- set source_paths = section.extra.section_path | default(value="blog/") -%}
{%- if source_paths is iterable -%}
    {%- set paths = source_paths -%}
{%- else -%}
    {%- set paths = [source_paths] -%}
{%- endif %}
{%- set all_posts = [] -%}
{%- for path in paths -%}
    {%- if lang == config.default_language %}
        {%- set section_item = get_section(path=path ~ "_index.md") -%}
    {%- else %}
        {%- set section_item = get_section(path=path ~ "_index." ~ lang ~ ".md") -%}
    {%- endif %}
    {%- set_global all_posts = all_posts | concat(with=section_item.pages) -%}
{%- endfor %}

{% for year, posts in all_posts | group_by(attribute="year") %}
{% if posts | length > 0 %}
{# Logic to display the posts goes here #}