mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 02:37:59 +02:00
fix(v2): add base URL to content attribute of head tags PWA (#5185)
This commit is contained in:
parent
cda09237cc
commit
54e4b02666
2 changed files with 16 additions and 4 deletions
|
@ -90,9 +90,21 @@ function plugin(context, options) {
|
||||||
const headTags = [];
|
const headTags = [];
|
||||||
if (isProd && pwaHead) {
|
if (isProd && pwaHead) {
|
||||||
pwaHead.forEach(({tagName, ...attributes}) => {
|
pwaHead.forEach(({tagName, ...attributes}) => {
|
||||||
if (attributes.href && !attributes.href.startsWith(baseUrl)) {
|
['href', 'content'].forEach((attribute) => {
|
||||||
attributes.href = normalizeUrl([baseUrl, attributes.href]);
|
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({
|
return headTags.push({
|
||||||
tagName,
|
tagName,
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -232,7 +232,7 @@ const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;
|
||||||
{
|
{
|
||||||
tagName: 'meta',
|
tagName: 'meta',
|
||||||
name: 'msapplication-TileImage',
|
name: 'msapplication-TileImage',
|
||||||
href: 'img/docusaurus.png',
|
content: 'img/docusaurus.png',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tagName: 'meta',
|
tagName: 'meta',
|
||||||
|
|
Loading…
Add table
Reference in a new issue