Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

img-grid occasionally fails to find file -- seems like being resolved by wrong page #115

Closed
pleasantone opened this issue Feb 20, 2024 · 1 comment

Comments

@pleasantone
Copy link
Contributor

pleasantone commented Feb 20, 2024

Scenario:

I use {{< bs/img-grid "attendees.yaml" >}} to build an image grid of photos of people attending an event on a page.
The images are stored in the page bundle, in a subdirectory e.g. attendess/foo.jpg.

Anomaly:
Page always builds correctly in production.
Sometimes, in development, e.g. if one edited that page bundle's index.md, the images are not found.
If one triggers a rebuild, they will often be found.
github.com/hugomods/images/layouts/partials/images/image.html reports that the images that were part of the page resources was not found.

Analysis:
By adding some debugging, I've determined that when things have failed, it has occurred because image.html's $page variable is Page(/_index.md) not Page(/events/2024-baja-mexico/index.md) (the proper page).

Strongly enough, the call to GitHub.com/hugomods/bootstrap/layouts/partials/bootstrap/img-grid.html (one level up in the call stack) is always called with the proper Page set.

Here's my debugging output when it fails:

WARN  DATA: page=Page(/events/2024-baja-mexico/index.md) key=attendees data=[map[src:attendees/mug_mattgor.jpg title:Matt "Gecko" Gordon] map[src:attendees/mug_stuart.jpg title:Uncle Stu] map[src:attendees/mug_ian.jpg title:Ian] map[src:attendees/mug_hunt.jpg title:Huntley] map[src:attendees/mug_ich.jpg title:Ichabod] map[src:attendees/mug_raj.jpg title:Raj] map[src:attendees/mug_eminem.jpg title:Mike] map[src:attendees/mug_jake.jpg title:Jake] map[src:attendees/mug_milo.jpg title:Milo] map[src:attendees/mug_holland.jpg title:Holland Ja (unconfirmed)] map[src:attendees/mug_matthanley.jpg title:Matt Hanley (2 days)] map[src:attendees/mug_tuggle.jpg title:Steve Tuggle (2 days)] map[src:attendees/mug_charles.jpg title:Charles (unconfirmed)] map[src:attendees/mug_dan.jpg title:Dan G (unconfirmed)]]

WARN  looking for page resources getmatch path=attendees/mug_mattgor.jpg page=Page(/_index.en.md) res=<nil>
WARN  image not found: attendees/mug_mattgor.jpg
WARN  looking for page resources getmatch path=attendees/mug_stuart.jpg page=Page(/_index.en.md) res=<nil>
WARN  image not found: attendees/mug_stuart.jpg
...

Here is my debugging when it succeeded:

WARN  DATA: page=Page(/events/2024-baja-mexico/index.md) key=attendees data=[map[src:attendees/mug_mattgor.jpg title:Matt "Gecko" Gordon] map[src:attendees/mug_stuart.jpg title:Uncle Stu] map[src:attendees/mug_ian.jpg title:Ian] map[src:attendees/mug_hunt.jpg title:Huntley] map[src:attendees/mug_ich.jpg title:Ichabod] map[src:attendees/mug_raj.jpg title:Raj] map[src:attendees/mug_eminem.jpg title:Mike] map[src:attendees/mug_jake.jpg title:Jake] map[src:attendees/mug_milo.jpg title:Milo] map[src:attendees/mug_holland.jpg title:Holland Ja (unconfirmed)] map[src:attendees/mug_matthanley.jpg title:Matt Hanley (2 days)] map[src:attendees/mug_tuggle.jpg title:Steve Tuggle (2 days)] map[src:attendees/mug_charles.jpg title:Charles (unconfirmed)] map[src:attendees/mug_dan.jpg title:Dan G (unconfirmed)]]
WARN  looking for page resources getmatch path=attendees/mug_mattgor.jpg page=Page(/events/2024-baja-mexico/index.md) res=attendees/mug_mattgor.jpg
WARN  looking for page resources getmatch path=attendees/mug_stuart.jpg page=Page(/events/2024-baja-mexico/index.md) res=attendees/mug_stuart.jpg

My best guess is that something is partialCached when it shouldn't be, but this is really weird.. the page in question is just using a standard shortcut...

Full source code at https://github.com/goattrails/hb-goattrails/blob/main/content/events/2024-baja-mexico/index.md

My debugging diffs:
bootstrap.patch
images.patch

@pleasantone
Copy link
Contributor Author

Update:

Happens when .Page for this short-cut is nil. Looks like we cover it with

$page = default page .Page in image.html why is .Page nil when it was just fine when being called one step up by the bootstrap bs/img shortcut pulling in the data file?

WARN  page=Page(/_index.en.md) .Page=<nil> $page=Page(/_index.en.md)
WARN  looking for page resources getmatch path=attendees/mug_mattgor.jpg page=Page(/_index.en.md) res=<nil>
WARN  image not found: attendees/mug_mattgor.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant