@canopy-iiif/app 0.9.2 → 0.9.3

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/lib/build/mdx.js CHANGED
@@ -11,6 +11,42 @@ const {
11
11
  ensureDirSync,
12
12
  withBase,
13
13
  } = require("../common");
14
+
15
+ const EXTRA_REMARK_PLUGINS = (() => {
16
+ try {
17
+ const absPath = path.resolve(process.cwd(), "packages/helpers/docs/remark-code-meta.js");
18
+ if (fs.existsSync(absPath)) {
19
+ const plugin = require(absPath);
20
+ if (typeof plugin === "function") return [plugin];
21
+ }
22
+ } catch (_) {}
23
+ return [];
24
+ })();
25
+
26
+ function buildCompileOptions(overrides = {}) {
27
+ const base = {
28
+ jsx: false,
29
+ development: false,
30
+ providerImportSource: "@mdx-js/react",
31
+ jsxImportSource: "react",
32
+ format: "mdx",
33
+ };
34
+ const remarkPlugins = [];
35
+ if (overrides && Array.isArray(overrides.remarkPlugins)) {
36
+ remarkPlugins.push(...overrides.remarkPlugins);
37
+ }
38
+ if (EXTRA_REMARK_PLUGINS.length) {
39
+ remarkPlugins.push(...EXTRA_REMARK_PLUGINS);
40
+ }
41
+ if (remarkPlugins.length) {
42
+ base.remarkPlugins = remarkPlugins;
43
+ }
44
+ if (overrides && typeof overrides === "object") {
45
+ const { remarkPlugins: _omit, ...rest } = overrides;
46
+ Object.assign(base, rest);
47
+ }
48
+ return base;
49
+ }
14
50
  const yaml = require("js-yaml");
15
51
  const { getPageContext } = require("../page-context");
16
52
 
@@ -255,15 +291,7 @@ async function loadAppWrapper() {
255
291
  const { compile } = await import("@mdx-js/mdx");
256
292
  const raw = await fsp.readFile(appPath, "utf8");
257
293
  const { content: source } = parseFrontmatter(raw);
258
- let code = String(
259
- await compile(source, {
260
- jsx: false,
261
- development: false,
262
- providerImportSource: "@mdx-js/react",
263
- jsxImportSource: "react",
264
- format: "mdx",
265
- })
266
- );
294
+ let code = String(await compile(source, buildCompileOptions()));
267
295
  // MDX v3 default export (MDXContent) does not forward external children.
268
296
  // When present, expose the underlying layout function as __MDXLayout for wrapping.
269
297
  if (
@@ -307,13 +335,7 @@ async function compileMdxFile(filePath, outPath, Layout, extraProps = {}) {
307
335
  const { compile } = await import("@mdx-js/mdx");
308
336
  const raw = await fsp.readFile(filePath, "utf8");
309
337
  const { content: source } = parseFrontmatter(raw);
310
- const compiled = await compile(source, {
311
- jsx: false,
312
- development: false,
313
- providerImportSource: "@mdx-js/react",
314
- jsxImportSource: "react",
315
- format: "mdx",
316
- });
338
+ const compiled = await compile(source, buildCompileOptions());
317
339
  const code = String(compiled);
318
340
  ensureDirSync(CACHE_DIR);
319
341
  const relCacheName =
@@ -449,13 +471,7 @@ async function compileMdxToComponent(filePath) {
449
471
  const { compile } = await import("@mdx-js/mdx");
450
472
  const raw = await fsp.readFile(filePath, "utf8");
451
473
  const { content: source } = parseFrontmatter(raw);
452
- const compiled = await compile(source, {
453
- jsx: false,
454
- development: false,
455
- providerImportSource: "@mdx-js/react",
456
- jsxImportSource: "react",
457
- format: "mdx",
458
- });
474
+ const compiled = await compile(source, buildCompileOptions());
459
475
  const code = String(compiled);
460
476
  ensureDirSync(CACHE_DIR);
461
477
  const relCacheName =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopy-iiif/app",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Mat Jordan <mat@northwestern.edu>",
@@ -22,7 +22,8 @@
22
22
  "import": "./lib/orchestrator.js",
23
23
  "require": "./lib/orchestrator.js",
24
24
  "default": "./lib/orchestrator.js"
25
- }
25
+ },
26
+ "./docs-legacy-compat": "./docs-legacy-compat.mjs"
26
27
  },
27
28
  "files": [
28
29
  "lib/**",