Skip to content

fix(gallery): handle scheme-relative og:url in getImageJSON - #27

Merged
jjsnack merged 1 commit into
mainfrom
fix/scheme-relative-og-url
Aug 15, 2026
Merged

fix(gallery): handle scheme-relative og:url in getImageJSON#27
jjsnack merged 1 commit into
mainfrom
fix/scheme-relative-og-url

Conversation

@jjsnack

@jjsnack jjsnack commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • getImageJSON() built the index.json fetch URL from the og:url meta tag via new URL('index.json', ogUrl). When Hugo's baseURL is unset (the normal case for local hugo server — prod injects it at deploy time via -b), .Permalink renders scheme-relative (//host/path), which URL() rejects as an invalid base and throws synchronously.
  • That throw rejected the createResource(getImageJSON) promise, so every _default-layout page (the scatter gallery) showed the Couldn't load images. fallback in local dev.
  • Fix: if the og:url content starts with //, prepend the current page's window.location.protocol before using it as the URL base.

Test plan

  • pnpm lint:check / prettier clean on the changed file
  • pnpm build completes clean
  • Reproduced the bug against the parent photography-website site (hugo server with no -b), confirmed og:url renders scheme-relative and the page shows the fallback
  • Verified the fix's URL resolution logic directly against the reproduced scheme-relative value, and confirmed the resolved index.json endpoint returns 200

🤖 Generated with Claude Code

https://claude.ai/code/session_01PgXHXLyhCD8mRjE5GsJ3We

Hugo emits a scheme-relative Permalink ("//host/path") when baseURL is
unset, which is the case for plain `hugo server` (baseURL is normally
injected at deploy time via `-b`). new URL() rejects a scheme-relative
string as a base, throwing synchronously and surfacing "Couldn't load
images." on every _default-layout page in local dev.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PgXHXLyhCD8mRjE5GsJ3We
@jjsnack
jjsnack merged commit efc52f7 into main Aug 15, 2026
3 checks passed
@jjsnack
jjsnack deleted the fix/scheme-relative-og-url branch August 15, 2026 05:45
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

Successfully merging this pull request may close these issues.

1 participant