fix(v2): add base URL to content attribute of head tags PWA (#5185)

This commit is contained in:
Alexey Pyltsyn 2021-07-16 12:56:00 +03:00 committed by GitHub
parent cda09237cc
commit 54e4b02666
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View file

@ -90,9 +90,21 @@ function plugin(context, options) {
const headTags = [];
if (isProd && pwaHead) {
pwaHead.forEach(({tagName, ...attributes}) => {
if (attributes.href && !attributes.href.startsWith(baseUrl)) {
attributes.href = normalizeUrl([baseUrl, attributes.href]);
}
['href', 'content'].forEach((attribute) => {
const attributeValue = attributes[attribute];
if (!attributeValue) {
return;
}
const attributePath =
!!path.extname(attributeValue) && attributeValue;
if (attributePath && !attributePath.startsWith(baseUrl)) {
attributes[attribute] = normalizeUrl([baseUrl, attributeValue]);
}
});
return headTags.push({
tagName,
attributes,

View file

@ -232,7 +232,7 @@ const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;
{
tagName: 'meta',
name: 'msapplication-TileImage',
href: 'img/docusaurus.png',
content: 'img/docusaurus.png',
},
{
tagName: 'meta',