Skip to content

fix(website): resolve the footer logo against the site base url - #425

Open
IanoNjuguna wants to merge 1 commit into
IntersectMBO:mainfrom
IanoNjuguna:fix/footer-logo-baseurl
Open

IanoNjuguna wants to merge 1 commit into
IntersectMBO:mainfrom
IanoNjuguna:fix/footer-logo-baseurl

Conversation

@IanoNjuguna

Copy link
Copy Markdown
Contributor

Description

The footer rendered <img src="img/intersect-logo.png">, the raw config string with no leading slash, so it resolved against the current route: fine on /, a 404 on every docs page.

logo.src now goes through useBaseUrl, which is what the stock navbar and the stock footer do with the same value. The config keeps the relative path, because that is the convention both of those follow.

One line of behaviour plus the import, and a comment saying why, since the next person to swizzle this footer will otherwise re-introduce it.

Fixes #424.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • I have tested these changes locally
  • I have checked for broken links

Checklist

  • My code follows the style guidelines
  • I have performed a self-review

Verification

tsc --noEmit -p tsconfig.json                        clean
npm run build                                        SUCCESS
footer img on /docs/getting-started/                 <img src="/img/intersect-logo.png" alt="" width="32" height="32">
footer img on /                                    <img src="/img/intersect-logo.png" alt="" width="32" height="32">
pages still emitting src="img/intersect-logo.png"    0

Before the change the first of those read src="img/intersect-logo.png", which is the request that 404s.

Notes

  • The hook is called before if (!footer) return null, so the hook order stays unconditional. Putting it after the early return would have worked on the current config and broken the rules of hooks the first time the footer were made optional.
  • Nothing in CI would have caught this: the path is a string in JSX, so onBrokenLinks never sees it. A <img> whose src is a plain string is invisible to every check we run, which is worth remembering for other swizzled assets.
  • The alternative fix, src: "/img/intersect-logo.png" in the config, works today but breaks if the site is ever served under a subpath, and it would leave the navbar and footer using two different conventions.

logo.src was rendered verbatim, and the config writes it without a leading
slash, so the mark loaded on / and 404'd on every docs page. useBaseUrl is what
the stock navbar and footer do with the same value.

This branch has not been deployed

No deployments
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.

docs(site): the footer logo 404s on every page except the homepage

1 participant