hextra icon indicating copy to clipboard operation
hextra copied to clipboard

Feature Request: Closed Shortcode for card/feature-card

Open KStocky opened this issue 4 months ago • 4 comments

Feature Description

I would like the ability to create cards (both feature-card and regular card) that are closed, and their inner content is rendered as markdown in the card.

Problem/Solution

Currently, we have image, or image-less cards. However, if we had a card that was implemented as a closed shortcode: e.g.

{{< card-closed >}}
//Insert inner content here
{{< /card-closed >}}

we would be able to create cards that have code snippets too. This would be quite useful for sites that want to show code snippets as part of a gallery.

Alternatives Considered

The alternative would be just to take a screenshot of the code snippets and use the image. However, this isn't nearly as good of a solution because it would not be reactive to light/dark theme switches

Additional Context

I have a somewhat working implementation in my CardsWithInner branch on my fork. The issue that I have with my implementation is that it could do with some additional CSS to make the code match with the card a little better. You can see examples of this in the documentation for hextra and cards in the same branch.

KStocky avatar Aug 24 '25 15:08 KStocky

Thanks for the feature request! Do you have any screenshots to show what it would look like?

imfing avatar Aug 27 '25 18:08 imfing

Yeah so these are the proposed docs for the hextra/feature-cards version

Image

And then for regular cards:

Image

The issue is that the rounded background of the code snippet doesn't look right in the card: To better show the issue, here is the feature card version with the light theme:

Image

Ideally you would want the code snippet background to fill the entire bottom of the card just like with image cards, but this does not.

I have this on my fork because it is good enough for me, but I think this could be good feature for mainline hextra... If someone could help with the CSS a little :)

KStocky avatar Aug 29 '25 10:08 KStocky

I have just enabled github pages on my fork so you have have a look at what it currently looks like here https://kstocky.github.io/hextra/docs/guide/shortcodes/hextra/#hextrafeature-card-closed

KStocky avatar Aug 29 '25 15:08 KStocky

there's a similar feature for cards being actively worked on in #809

imfing avatar Aug 31 '25 11:08 imfing