Accessing indifferently `foo/` and `foo/bar/`

Hi everyone,

I would like to achieve something like this:

{% set a = get_page(path="foo/" ~ filename ~ ".md", required=false) %}
{% if not a %}
  {% set a = get_page(path="foo/" ~ filename ~ "/") %}
{% endif %}

i.e., loading a page of a known section but with a filename that can either refer to a file or a folder (because of “colocation”). However:

  • the required argument that exists for load_data does not exist for get_page;
  • is it possible to factor this into some sort of macro? As it will be used quite a few times, and it would be much more handy to write something like a = get_page_from(section="foo", filename=filename).

Thanks a lot