halogenica / beautifulhugo

Theme for the Hugo static website generator
Other
1.13k stars 601 forks source link

Fallback to first bigimg when JavaScript disabled #456

Closed WJBarnes456 closed 1 year ago

WJBarnes456 commented 1 year ago

Solves https://github.com/halogenica/beautifulhugo/issues/455 by statically configuring the page source to use the source and description of the first image in bigimg. When the description is empty, also pre-hides the description box.

When JavaScript is enabled, this theme's main.js (https://github.com/halogenica/beautifulhugo/blob/master/static/js/main.js) takes over and will overwrite this style attribute, changing the image in use.

WJBarnes456 commented 1 year ago

I'm happy with the no-JS version not including the link rendering, but there's a very simple extension to render all Markdown in the desc attribute by piping $firstimg.desc into markdownify.

This would then introduce a feature disparity the other way around; I'm not sure if that's preferable or not, so I've omitted it from the PR.