@myst-theme/common 0.13.6 → 0.14.0

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,CA6Ed;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,13 @@ 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.options.style)
153
+ data.options.style = updateUrl(data.options.style);
154
+ if (data.parts) {
155
+ Object.values(data.parts).forEach(({ mdast }) => {
156
+ updateMdastStaticLinksInplace(mdast, updateUrl);
157
+ });
158
+ }
124
159
  // Update the thumbnails to point at the CDN
125
160
  (_c = data.projects) === null || _c === void 0 ? void 0 : _c.forEach((project) => {
126
161
  if (project.banner)
@@ -153,6 +188,11 @@ export function updateSiteManifestStaticLinksInplace(data, updateUrl) {
153
188
  if (page.thumbnailOptimized)
154
189
  page.thumbnailOptimized = updateUrl(page.thumbnailOptimized);
155
190
  });
191
+ if (project.parts) {
192
+ Object.values(project.parts).forEach(({ mdast }) => {
193
+ updateMdastStaticLinksInplace(mdast, updateUrl);
194
+ });
195
+ }
156
196
  });
157
197
  return data;
158
198
  }
@@ -186,32 +226,7 @@ export function updatePageStaticLinksInplace(data, updateUrl) {
186
226
  }
187
227
  const allMdastTrees = [data, ...Object.values((_h = (_g = data.frontmatter) === null || _g === void 0 ? void 0 : _g.parts) !== null && _h !== void 0 ? _h : {})];
188
228
  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
- });
229
+ updateMdastStaticLinksInplace(mdast, updateUrl);
215
230
  });
216
231
  return data;
217
232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myst-theme/common",
3
- "version": "0.13.6",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -19,9 +19,9 @@
19
19
  "build": "npm-run-all -l clean -p build:esm"
20
20
  },
21
21
  "dependencies": {
22
- "myst-common": "^1.7.8",
23
- "myst-config": "^1.7.8",
24
- "myst-spec-ext": "^1.7.8",
22
+ "myst-common": "^1.7.9",
23
+ "myst-config": "^1.7.9",
24
+ "myst-spec-ext": "^1.7.9",
25
25
  "nbtx": "^0.2.3",
26
26
  "unist-util-select": "^4.0.3"
27
27
  }