Open
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-flight checklist
Motivation
Allows users to provide a function with some static options that are used to generate social card urls for the site inside docusaurus.config.js. The function is run in a Node environment, so users can access and create local files. Users can also provide a static url.
In addition, I have a social card generation service hosted here. The code is here. The preview page is a work-in-progress, but the API is fully functioning.
There were a few extra changes I had to make. Mainly shuffling around a few util functions to avoid adding dependencies when possible.
urlfunction for docusaurus.config.jsOne issue with this approach is that I don't think there is a way to use the function for JSX pages. As a workaround, in
<Layout>, I added an option for users to set thesocialCardUrlmanually. This is a bit repetitive though. I have another implementation that works for JSX pages by passing the function to React. However, this does prevent any access to the local filesystem, limiting the flexibility of the function. What are your opinions on this implementation?This new feature replaces the theme config
imageoption. Should we remove that option?Test Plan
Updated the current plugin tests with socialCardUrls.
Tested the default social card url generator function with the following:
For each type of page (docs, blog, pages)
Dogfooding:
<Layout>.Test links
Deploy preview: https://deploy-preview-7836--docusaurus-2.netlify.app
Dogfooding page: https://deploy-preview-7836--docusaurus-2.netlify.app/tests/pages/social-card-service-tests/
There are 14 different components in theme-classic that use , which I am using to set
og:imageandtwitter:image. Below, I have a link to each type of page, as well as a preview page for its social card.Page: https://deploy-preview-7836--docusaurus-2.netlify.app/not-a-page
Card: Preview sites don't work, probably because the page is not found. However, the meta tag is there.
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/blog/archive
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fblog%2Farchive
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/blog
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fblog
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/blog/2021/03/09/releasing-docusaurus-i18n
Card: Preview doesn't work because there is another image overriding it. However, the meta tag is on the page: https://docusaurus-og-image.vercel.app/Releasing%20Docusaurus%20i18n?authorName=S%C3%A9bastien%20Lorber&authorImage=https%3A%2F%2Fgithub.com%2Fslorber.png&projectName=Docusaurus&projectLogo=https%3A%2F%2Fdocusaurus.io%2Fimg%2Fdocusaurus.svg&markdown=true&docusaurus=true&theme=light&
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/blog/tags
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fblog%2Ftags
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/blog/tags/adoption
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fblog%2Ftags%2Fadoption
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/docs/category/getting-started
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fdocs%2Fcategory%2Fgetting-started
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/docs/installation
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fdocs%2Finstallation
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/tests/docs/tags/b
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Ftests%2Fdocs%2Ftags%2Fb
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/tests/docs/tags
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Ftests%2Fdocs%2Ftags
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/tests/pages/social-card-service-tests
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Ftests%2Fpages%2Fsocial-card-service-tests
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/examples/markdownPageExample
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fexamples%2FmarkdownPageExample
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2F
Page: https://deploy-preview-7836--docusaurus-2.netlify.app/changelog
Card: https://www.opengraph.xyz/url/https%3A%2F%2Fdeploy-preview-7836--docusaurus-2.netlify.app%2Fchangelog
Related issues/PRs