welpo / tabi

A modern Zola theme with search, multilingual support, optional JavaScript, a perfect Lighthouse score, and a focus on accessibility.
https://welpo.github.io/tabi/
MIT License
97 stars 32 forks source link

"All posts ->" in main page links to "blog/" is hardcoded, so dead link if other section was chosen for main page #292

Closed Dalker closed 2 months ago

Dalker commented 2 months ago

Bug Report

Environment

Zola version: 0.18.0 tabi version or commit: d0dd37ef1e16dc1ed5171f7c6b99ec2d18ffeafa

Expected Behavior

When section_path in the [extra] section of front-matter of main content _index.md is set, it should be used to generate the list of posts visible in the main (first) page of the site. If, furthermore, max_posts = 1 is set, the "All posts ->" link that is then generated below the single post (the last post) visible on the main page should also point to the same section chosen with section_path

Current Behavior

If max_posts is greater than or equal to 2, everything works fine. With max_posts = 1, "All posts ->" points to a possibly non-existing "blog" section.

A little investigation shows that the issue comes from the templates/macros/list_posts.html file, where "blog" is hard-coded, instead of using the section_path chosen by the user.

Step to Reproduce

Place the following in content/_index.md for a site in which there is no blog subdirectory (aka section):

[extra]
section_path = "some_existing_section/_index.md"
max_posts = 1
welpo commented 2 months ago

Hi Daniel!

Thanks for reporting this bug.

Would you be interested in creating a PR for the fix?

Dalker commented 2 months ago

Hello Óscar and first of all thanks for making your great theme publicly available!

I'd be happy to contribute if I can manage to sort out a general solution, but it doesn't seem to be so simple (for my personal use I just did a quickfix replacing one hard-coded section name by another).

The difficulty is that the list_posts macro must be made aware of the target section, e.g. passed as an extra argument, ~but some of its callers do not seem to have that information available, notably tags/single.html -- or at least not simply by the name section~ (I'm new to zola so I might be missing something here).

EDIT: never mind, I figured out how to fix at least the specific problem in a somewhat general way; will send a pull request a bit later when I get the time to tidy it up

welpo commented 2 months ago

Thanks for the report and the fix!