typo icon indicating copy to clipboard operation
typo copied to clipboard

Displaying a list of posts on the homepage from multiple collections.

Open AlexanderZhirov opened this issue 7 months ago • 5 comments

Adjusted the parameter for displaying recent posts on the home page. Considering that we can create multiple sections, it makes more sense to use their list.

In this case, we create an array where we specify the list of sections from which we can display our posts.

AlexanderZhirov avatar Apr 18 '25 18:04 AlexanderZhirov

Can you please include an example of the result? Also, this will break current configs, I would add something like homeCollectionList parameter, which, if populated, overrides the current homeCollection.

tomfran avatar Apr 19 '25 09:04 tomfran

Won't an additional parameter for the same entity be excessive? I think it complicates the configuration by having two parameters. If we have a single parameter as a list, we can simply modify it, and if nothing is added, then nothing is displayed.

AlexanderZhirov avatar Apr 19 '25 22:04 AlexanderZhirov

Though you're right—backward compatibility breaks existing configurations. We might have to add an extra parameter after all. I'll adjust my changes.

AlexanderZhirov avatar Apr 19 '25 22:04 AlexanderZhirov

I agree that it would be better a single parameter, but I feel this would break a lot of configs.

Do you know maybe if there's a way to make both a list and a single string work together? Maybe something like:

if is instance list: render list else: render as is

tomfran avatar Apr 20 '25 08:04 tomfran

Thank you for the update, I was thinking of something tho. Since this setup does not allow to have a title for each collection, the result could look a bit off, for instance, I would expect something like:

# Collection title
- ...
- ...
- ...

# Second collection title
- ...
- ...
- ...

So, since we are breaking the config anyway, what would you say in adding something along those lines:

hugo.toml

[[params.home_collections]]
title = 'First Collection'
collection = "first"

[[params.home_collections]]
title = 'Second Collection'
collection = "second"

We could treat the current homeCollectionTitle and homeCollectionTitle as is, and simply render in the same way elements from those params (as we do for social icons and the menu). We don't break compatibility, and I will simply remove the existing params from the suggested config on the Wiki.

I know this requires more work, but it would be way nicer I feel, what do you think? Sorry for not thinking about this from the start.

tomfran avatar Apr 24 '25 20:04 tomfran