mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 03:26:57 +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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue