Moondeer
Moondeer

Here’s a nice example of the kind of ridiculous I must embrace when writing Hugo code (f$&k I miss Swift). What you are looking at is a simple check for the use of a pair of shortcodes (hacked to f$&k so it works on the homepage, taxonomy pages, and single pages).

cc @sod

|
Embed
sod
sod

@Moondeer Wow, that's one impressive – and kind of intimidating – piece of code. 😅

|
Embed
Moondeer
Moondeer

@sod I found discussion of the problem on a forum or I'd never have known WTF the problem was. With list pages you have to check every page in the list … and … for whatever reason … on the home page you have to go a layer deeper.

|
Embed
sod
sod

@Moondeer I probably lack too much context here, but judging by the comment at the bottom, you're including stylesheets based on if a shortcode is used or not. Is that right? Could an alternative be to just always have the stylesheet? That way, you could just get rid of the entire if/else block.

|
Embed
In reply to
Moondeer
Moondeer

@sod yeah, this one is trivial and I kinda just wanted to test it out … it was a bigger deal when Javascript was also being injected.

|
Embed