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: add og:title,url,description meta tags and prefix og:image with host #1769

Merged
merged 10 commits into from Jan 20, 2023

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Dec 21, 2022

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The OpenGraph spec requires:

  • og:title - The title of your object as it should appear within the graph, e.g., "The Rock".
  • og:type - The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
  • og:image - An image URL which should represent your object within the graph.
  • og:url - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "https://www.imdb.com/title/tt0117500/".

Two url related issues come up for future attention:

  • support for trailing/non-trailing slash configuration - particularly platforms like netlify which redirect to trailing slash are relevant. I've bypassed this by currently rendering og:url for whatever url was actually accessed, but this is not optimal - ideally there's a canonical form of the url.
  • support for rel=canonical URLs for document driven mode - this depends on the point above

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added the bug Something isn't working label Dec 21, 2022
@netlify
Copy link

netlify bot commented Dec 21, 2022

βœ… Deploy Preview for nuxt-content ready!

Name Link
πŸ”¨ Latest commit 308b97f
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/63c58302d86238000740e829
😎 Deploy Preview https://deploy-preview-1769--nuxt-content.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@danielroe danielroe changed the title fix: add og:title and og:url meta tags and prefix og:image with host fix: add og:title,url,description meta tags and prefix og:image with host Dec 21, 2022
@danielroe danielroe self-assigned this Dec 21, 2022
@danielroe danielroe marked this pull request as ready for review December 21, 2022 16:47
@danielroe danielroe requested review from Tahul and farnabaz and removed request for Tahul December 21, 2022 16:54
@Atinux
Copy link
Member

Atinux commented Dec 21, 2022

Thanks @danielroe , what would you suggest for canonical?

@danielroe
Copy link
Member Author

danielroe commented Dec 21, 2022

I would recommend, for now, we add a trailingSlash: true | false option to documentDriven in conten, and then enable the canonical code that's commented out here. Happy to add it to this PR if it's an acceptable approach. I wouldn't suggest implementing any kind of redirection between them (and tbh that isn't required if you have a canonical set).

Copy link
Member

Atinux commented Dec 22, 2022

No need for redirect if we set the canonical meta tag indeed.

Those trailingSlash should be ported back to Nuxt at one point like we had on Nuxt 2.

Happy to update the PR and uncomment your code?

@farnabaz
Copy link
Member

What should we do with canonical? Uncomment or keep it commented?

Also, What do you think about using HOST header and window.location to find the host if it isn't defined in the config?

/cc @Atinux @danielroe

Copy link
Member

Atinux commented Jan 16, 2023

I like the idea of trying to guess the host as much as possible

Copy link
Member

Atinux commented Jan 16, 2023

Regarding the canonical, what do you suggest @danielroe ?

@danielroe
Copy link
Member Author

Sorry for the delay on this! I've guarded open graph integration behind process.server check (as it's not useful on client-side) and added host guess from host header - nice idea.

Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

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

πŸ‘

@farnabaz farnabaz merged commit 383f707 into main Jan 20, 2023
@farnabaz farnabaz deleted the fix/og-title branch January 20, 2023 15:14
@farnabaz farnabaz mentioned this pull request Jan 23, 2023
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.

None yet

3 participants