chipzoller / hugo-clarity

A theme for Hugo based on VMware Clarity
Other
582 stars 267 forks source link

Ensure builds won't choke on 404ed remote image references #305

Closed rootwork closed 2 years ago

rootwork commented 2 years ago

This PR...

Changes / fixes

Screenshots (if applicable)

N/A really.

Testing

The only context in which the code change should affect anything is when you reference an image with a full URL that leads to a 404, like https://example.com/doesnotexist.png.

Whereas before it would try to evaluate the result, Hugo will choke if the result is empty. So now it first checks to see if the result exists, and only if it does will it evaluate it.

If you're looking directly at the code, GitHub's diffs might be confusing. I really just wrapped what was already there using {{- with $image }}.

Checklist

Ensure you have checked off the following before submitting your PR.