-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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(v2): fix external URL for og:image tag #2420
Conversation
Deploy preview for docusaurus-2 failed. Built with commit 6d5c797 https://app.netlify.com/sites/docusaurus-2/deploys/5e71f246330f8100084ac4e6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
This does not work normally. docusaurus/packages/docusaurus/src/client/exports/useBaseUrl.js Lines 10 to 28 in 32c1a92
/^\/(?!\/)/.test('/foo.jpg') // true
/^\/(?!\/)/.test('foo.jpg') // false
/^\/(?!\/)/.test('foo/foo.jpg') // false |
@38elements thank you for the report. We will rework this function, so do not change this PR. |
@lex111 import isInternalUrl from '@docusaurus/isInternalUrl';
// ...
let metaImageUrl = siteUrl + useBaseUrl(metaImage);
if (!isInternalUrl(metaImage)) {
metaImageUrl = metaImage;
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this is great!
I think we need some sort of normalizing function that will ensure between each URL segment there's only one
|
Oops premature merging. Probably some formatting issue. I'll fix it later tonight, sorry about that. |
Motivation
https://github.com/facebook/docusaurus/blob/2b6e4409704fb20a39a9273b1b051065f0eb8079/website/docs/theme-classic.md#meta-image
Currently, when url is setted to
themeConfig.image
, this does not work as below.https://example.comhttps://example.com/img/foo.png
This fixes it.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)