Page context in shortcodes

I’ve asked similar questions before, and I guess It’s not currently possible.

But this and similar stuff seems more and more like a very important feature to me.

Take the figure shortcode as an example. I would like to style my figures differently when on the home page.

So one would think that I could access .IsPage and .IsNode inside the shortcode, but no.

OK, so then one should believe that I can send it as a parameter in the shortcode itself:

{{% figure src="/img/someimage.jpg" class="{{ .IsPage }}" %}}

But not.

The simple solution is to pass formatting related data on page/node (at least the two above) on to the shortcode data struct.

This is a very quick fix, and I can add a PR for it – but thought I should disucss it here first, maybe someone is seeing an easier or better solution.

And my Hugo-branch has drifted far enough away from master as it is :slight_smile:

OK - I see I have the Page available on the short code, but that does me no good … as it is the same rendered content that is reused on the index page… So I guess this isn’t easilly fixable right now.

OK, so the “adding a class to figure” example was a little lame - I can easiliy fix that with CSS selectors. A better example would be to show img with “_thumb.jpg” suffix on list page. But as stated above, this is currently not possible.

Is this possible nowadays? I’m trying to do this.