mod-build 4.0.106-beta.3 → 4.0.106-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "4.0.106-beta.3",
3
+ "version": "4.0.106-beta.5",
4
4
  "description": "Share components for S3 sites.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -8,7 +8,7 @@ function getPictureObjectsWithUseCDN(node, found = []) {
8
8
  return found;
9
9
  }
10
10
 
11
- if (node.useCDN && (node.img || node.svg)) {
11
+ if (node.useCDN && (node.img || node.svg || node.url)) {
12
12
  found.push(node);
13
13
  }
14
14
 
@@ -22,7 +22,7 @@ function getPictureObjectsWithUseCDN(node, found = []) {
22
22
  }
23
23
 
24
24
  async function fetchGlobalImageAndUpdateSrc(picture) {
25
- const { img, svg, source } = picture;
25
+ const { img, svg, source, url } = picture;
26
26
  let imagesToDownload = [];
27
27
  if (img) {
28
28
  if (img.attributes && img.attributes.src) {
@@ -60,6 +60,14 @@ async function fetchGlobalImageAndUpdateSrc(picture) {
60
60
  });
61
61
  }
62
62
 
63
+ if (url) {
64
+ let bgUrl = url;
65
+ if (bgUrl.startsWith('/')) {
66
+ bgUrl = bgUrl.slice(1);
67
+ }
68
+ imagesToDownload.push(bgUrl);
69
+ }
70
+
63
71
  if (imagesToDownload.length === 0) {
64
72
  return;
65
73
  }
@@ -90,6 +98,10 @@ async function fetchGlobalImageAndUpdateSrc(picture) {
90
98
  });
91
99
  }
92
100
 
101
+ if (url) {
102
+ picture.url = `/${defaultSettings.assetsSubfolder}${url}`;
103
+ }
104
+
93
105
  // remove picture.useCDN
94
106
  delete picture.useCDN;
95
107
 
@@ -103,8 +115,8 @@ async function downloadImage(url) {
103
115
  return null;
104
116
  }
105
117
  // download the image and put in imagePath
118
+ const fileUrl = `https://${defaultSettings.nodeEnv}/quote/resources/assets/${url}`
106
119
  try {
107
- const fileUrl = `https://${defaultSettings.nodeEnv}/quote/resources/assets/${url}`
108
120
  const response = await fetch(fileUrl);
109
121
  if (!response.ok) {
110
122
  throw new Error(`Error downloading image ${fileUrl}: ${response.statusText}`);