@myst-theme/common 0.13.6 → 0.13.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAkB,UAAU,EAAE,MAAM,YAAY,CAAC;AAOnF,KAAK,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAG7D,wBAAgB,UAAU,CACxB,MAAM,CAAC,EAAE,YAAY,EACrB,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,GAAG,SAAS,CAM7B;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,GAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAyB,GAClD,OAAO,EAAE,GAAG,SAAS,CA+BvB;AAeD,wBAAgB,cAAc,CAC5B,MAAM,CAAC,EAAE,YAAY,EACrB,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,MAAM,GACZ,WAAW,CAab;AAED,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAEzC,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,SAAS,GACnB,YAAY,CAkEd;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAqD/F;AAED,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAEzD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAkB,UAAU,EAAE,MAAM,YAAY,CAAC;AAQnF,KAAK,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAG7D,wBAAgB,UAAU,CACxB,MAAM,CAAC,EAAE,YAAY,EACrB,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,GAAG,SAAS,CAM7B;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,GAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAyB,GAClD,OAAO,EAAE,GAAG,SAAS,CA+BvB;AAeD,wBAAgB,cAAc,CAC5B,MAAM,CAAC,EAAE,YAAY,EACrB,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,MAAM,GACZ,WAAW,CAab;AAED,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AA6BzC,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,SAAS,GACnB,YAAY,CA4Ed;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CA8B/F;AAED,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAEzD"}
package/dist/utils.js CHANGED
@@ -77,6 +77,34 @@ export function getFooterLinks(config, projectSlug, slug) {
77
77
  };
78
78
  return footer;
79
79
  }
80
+ function updateMdastStaticLinksInplace(mdast, updateUrl) {
81
+ // Fix all of the images to point to the CDN
82
+ const images = selectAll('image', mdast);
83
+ images.forEach((node) => {
84
+ node.url = updateUrl(node.url);
85
+ if (node.urlOptimized) {
86
+ node.urlOptimized = updateUrl(node.urlOptimized);
87
+ }
88
+ });
89
+ const links = selectAll('link,linkBlock,card', mdast);
90
+ const staticLinks = links === null || links === void 0 ? void 0 : links.filter((node) => node.static);
91
+ staticLinks.forEach((node) => {
92
+ // These are static links to thinks like PDFs or other referenced files
93
+ node.url = updateUrl(node.url);
94
+ });
95
+ const outputs = selectAll('output', mdast);
96
+ outputs.forEach((node) => {
97
+ if (!node.data)
98
+ return;
99
+ walkOutputs(node.data, (obj) => {
100
+ // The path will be defined from output of myst
101
+ // Here we are re-assigning it to the current domain
102
+ if (!obj.path)
103
+ return;
104
+ obj.path = updateUrl(obj.path);
105
+ });
106
+ });
107
+ }
80
108
  export function updateSiteManifestStaticLinksInplace(data, updateUrl) {
81
109
  var _a, _b, _c;
82
110
  (_a = data.actions) === null || _a === void 0 ? void 0 : _a.forEach((action) => {
@@ -121,6 +149,11 @@ export function updateSiteManifestStaticLinksInplace(data, updateUrl) {
121
149
  data.options.logo_dark = updateUrl(data.options.logo_dark);
122
150
  if (data.options.favicon)
123
151
  data.options.favicon = updateUrl(data.options.favicon);
152
+ if (data.parts) {
153
+ Object.values(data.parts).forEach(({ mdast }) => {
154
+ updateMdastStaticLinksInplace(mdast, updateUrl);
155
+ });
156
+ }
124
157
  // Update the thumbnails to point at the CDN
125
158
  (_c = data.projects) === null || _c === void 0 ? void 0 : _c.forEach((project) => {
126
159
  if (project.banner)
@@ -153,6 +186,11 @@ export function updateSiteManifestStaticLinksInplace(data, updateUrl) {
153
186
  if (page.thumbnailOptimized)
154
187
  page.thumbnailOptimized = updateUrl(page.thumbnailOptimized);
155
188
  });
189
+ if (project.parts) {
190
+ Object.values(project.parts).forEach(({ mdast }) => {
191
+ updateMdastStaticLinksInplace(mdast, updateUrl);
192
+ });
193
+ }
156
194
  });
157
195
  return data;
158
196
  }
@@ -186,32 +224,7 @@ export function updatePageStaticLinksInplace(data, updateUrl) {
186
224
  }
187
225
  const allMdastTrees = [data, ...Object.values((_h = (_g = data.frontmatter) === null || _g === void 0 ? void 0 : _g.parts) !== null && _h !== void 0 ? _h : {})];
188
226
  allMdastTrees.forEach(({ mdast }) => {
189
- // Fix all of the images to point to the CDN
190
- const images = selectAll('image', mdast);
191
- images.forEach((node) => {
192
- node.url = updateUrl(node.url);
193
- if (node.urlOptimized) {
194
- node.urlOptimized = updateUrl(node.urlOptimized);
195
- }
196
- });
197
- const links = selectAll('link,linkBlock,card', mdast);
198
- const staticLinks = links === null || links === void 0 ? void 0 : links.filter((node) => node.static);
199
- staticLinks.forEach((node) => {
200
- // These are static links to thinks like PDFs or other referenced files
201
- node.url = updateUrl(node.url);
202
- });
203
- const outputs = selectAll('output', mdast);
204
- outputs.forEach((node) => {
205
- if (!node.data)
206
- return;
207
- walkOutputs(node.data, (obj) => {
208
- // The path will be defined from output of myst
209
- // Here we are re-assigning it to the current domain
210
- if (!obj.path)
211
- return;
212
- obj.path = updateUrl(obj.path);
213
- });
214
- });
227
+ updateMdastStaticLinksInplace(mdast, updateUrl);
215
228
  });
216
229
  return data;
217
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myst-theme/common",
3
- "version": "0.13.6",
3
+ "version": "0.13.7",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",