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

fix: og:image tags for /area/ and /climbs/ #1200

Merged
merged 2 commits into from
Nov 8, 2024
Merged

fix: og:image tags for /area/ and /climbs/ #1200

merged 2 commits into from
Nov 8, 2024

Conversation

julianlam
Copy link
Contributor

@julianlam julianlam commented Nov 7, 2024

What type of PR is this?(check all applicable)

  • refactor
  • feature
  • bug fix
  • documentation
  • optimization
  • other

Description

  • og:image tags for areas do not work (invalid URL)
  • og:image tags for climbs do not work (shows default south africa image)
    • Same issue as below, router is called twice, but og:image is not properly retrieved the first time due to null uid
  • og:image tags for profiles do not work (arguments are double escaped)
    • Upstream issue: head > meta > content escaping issue facebook/react#13838
    • Passing in restricted characters like & cause them to be escaped. There are workarounds but none that look simple (or maintainable) enough to implement.
    • When a user profile is loaded, useUserProfileSeo is called to load the photos for og:image
    • This is called by the react router, but the router is called twice. Once with a null uid (causing the og:image tag to be the default image), and a second time in-client causing the tags to be properly set in DOM. However, that is too late for link-preview services, because they don't parse js.

What this PR achieves

Fixed the above issues.

Screenshots, recordings

Notes

Query parameters are being escaped but I can't work around them. e.g. ?w=600&q=75 has the & replaced with & which isn't read correctly by the image server. (full quality image is sent)

@julianlam julianlam self-assigned this Nov 7, 2024
@julianlam julianlam added the bug Something isn't working label Nov 7, 2024
@julianlam julianlam marked this pull request as ready for review November 7, 2024 21:21
@clintonlunn clintonlunn linked an issue Nov 8, 2024 that may be closed by this pull request
@clintonlunn clintonlunn self-requested a review November 8, 2024 16:22
@julianlam julianlam changed the title Fix og:image tags for areas, profiles, climbs Fix og:image tags for areas Nov 8, 2024
@clintonlunn
Copy link
Collaborator

clintonlunn commented Nov 8, 2024

@julianlam just to point out I think the change you made to useClimbSeo only applies to the (soon to be deprecated/removed) /climbs/ page. The new /climb/ page does not have a generateMetadata() function yet, but should be added (out of scope for this issue). it is inheriting from

export const metadata: Metadata = {
title: 'OpenBeta',
description: 'Free rock climbing platform',
openGraph: {
description: 'OpenBeta is a free climbing platform. Join the community and share your knowledge today.',
images: '/south-africa-og.jpeg'
},
metadataBase: new URL(`https://${process.env.VERCEL_URL ?? 'http://localhost:3000'}`)
}

@julianlam
Copy link
Contributor Author

@clintonlunn Correct, I realized that earlier, which is why I made the commit. There still is an extra slash there, so having it removed is better, as the image 404s otherwise.

@clintonlunn
Copy link
Collaborator

image
image

Copy link
Collaborator

@clintonlunn clintonlunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. There are some discrepancies between the image url generation in useClimbSeo() (/climbs/ page) and the metadata for /area/ page maybe we can improve on that in the future since we're still seeing errors about an incorrect aspect ratio.

@clintonlunn clintonlunn changed the title Fix og:image tags for areas fix: og:image tags for /area/ and /climbs/ Nov 8, 2024
@clintonlunn clintonlunn merged commit 51375e5 into develop Nov 8, 2024
8 of 10 checks passed
@clintonlunn clintonlunn deleted the seo-images branch November 8, 2024 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image not loading in share preview for Climb and Area pages
2 participants