imfing / hextra

🔯 Modern, batteries-included Hugo theme for creating beautiful doc, blog and static websites
https://imfing.github.io/hextra/
MIT License
742 stars 177 forks source link

Make card(s) usable as partial #464

Closed benbarbour closed 1 month ago

benbarbour commented 2 months ago

Feature Description

I would like to make either a list template or a shortcode (or both) that displays a collection of pages as cards.

Problem/Solution

If I'm understanding things correctly, you can't call layouts/shortcodes/cards.html from within a partial, so it's functionality would need to be moved to a partial and the shortcode should become a very thin wrapper around the partial. I think, in general, this is a good pattern to follow. The Relearn theme seems to do it a lot.

Alternatives Considered

If found #439 but I don't think the workaround posted there works anymore.

MattDodsonEnglish commented 1 month ago

If found https://github.com/imfing/hextra/issues/439 but I don't think the workaround posted there works anymore.

@benbarbour I'm not sure as a partial, but that code should work as a shortcode. I.e. save it as layouts/shortcodes/card-list.html and then call it in the _index.md using {{< card-list >}}.

Or does that not work for you?