hugomods / images

:framed_picture: Hugo images module for processing images via URL query string and fragment, process images in Markdown way.
https://images.hugomods.com
MIT License
17 stars 3 forks source link

fix: remove invalid indentations and empty line break, so that the partial can be used in nested shortcode #33

Closed razonyang closed 10 months ago

razonyang commented 10 months ago

Alternative to #32.

TetraTheta commented 10 months ago

In my local test, this PR also fixes the problem issued in #32. Since my approach was brutal way of fixing the problem, I don't have any objection about this PR.


you'll noticed that the inner shortcode changes won't be hot-reload, you've to restart server and see the changes.

In fact, I have to stop the preview server, delete resources directory, then restart the server to get properly rendered result. If I don't, I often get multiple 'collapses' get expanded/collapsed in single click, which means something got wrong...

Not sure why, but this might be the reason of child header menu doesn't appear when parent header menu is clicked in production website. Re-building the site fixed the issue though.

Besides, I don't like to use nested shortcodes recently

But sometimes, I really want to use shortcode inside of another shortcode. In most cases, I use gallery/image at top-level, but sometimes, I have to 'hide' them inside of <details> or 'collapse' because they are not that important and just eating up article space.

In that case, I have to use nested shortcode, or use <details> HTML tag and put those things inside of it. But <details> tag isn't look nice without custom CSS which I can't do it well.

I don't know how other 'template engine' handles this 'nested shortcode'...

Alternatively, to avoid similar issues, you can pass the markdown content to gallery/image, and use RenderString (or sthelse) to render it.

I think that hurts the purpose of using shortcodes. Markdown texts can be passed to gallery/image and be processed in there, but the purpose of gallery/image is showing multiple images and optional caption. Passing text that might not be related to the image doesn't look good to me.

Yeah, this would be personal taste. I just prefer combining markdown text and shortcodes within another shortcode, rather than passing markdown text to inner shortcode, even though it causes problem sometimes...


Anyway, this PR looks good to me! Thank you a lot!

razonyang commented 10 months ago

You're welcome, I drafted a new release, I also added you as a collaborator on 30f968b65c67214c8937c76012455f8f4c515547 commit, thanks for your feedback.