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 = [];
|
||||
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,
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Add table
Reference in a new issue