fumadocs-core 10.1.0 → 10.1.2

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.
@@ -53,13 +53,21 @@ interface RemarkImageOptions {
53
53
  declare function remarkImage({ placeholder, }?: RemarkImageOptions): Transformer<Root$1, Root$1>;
54
54
 
55
55
  interface RemarkDynamicContentOptions {
56
- /** @defaultValue `process.cwd()` */
56
+ /**
57
+ * @defaultValue `vfile.cwd`
58
+ * @deprecated use the `cwd` option from remark instead
59
+ * */
57
60
  cwd?: string;
58
61
  /** @defaultValue true */
59
62
  trim?: boolean;
63
+ /**
64
+ * Resolve reference files relative to `vfile.path`
65
+ * @defaultValue false
66
+ */
67
+ relative?: boolean;
60
68
  /**
61
69
  * Filter specific element types
62
- * @defaultValue `['text','code']`
70
+ * @defaultValue ['text','code']
63
71
  * */
64
72
  visit?: string[];
65
73
  }
@@ -457,18 +457,20 @@ import { visit as visit3 } from "unist-util-visit";
457
457
  var regex = new RegExp("^\\|reference:(?<path>.+)\\|");
458
458
  function remarkDynamicContent(options = {}) {
459
459
  const {
460
- cwd = process.cwd(),
461
460
  trim = true,
461
+ relative = false,
462
462
  visit: filter = ["text", "code"]
463
463
  } = options;
464
- return (tree) => {
464
+ return (tree, file) => {
465
+ var _a;
466
+ const cwd = (_a = options.cwd) != null ? _a : file.cwd;
465
467
  visit3(tree, filter, (node) => {
466
- var _a;
467
- if (!("value" in node) || typeof node.value === "string")
468
+ const canReplace = "value" in node && typeof node.value === "string";
469
+ if (!canReplace)
468
470
  return;
469
471
  const result = regex.exec(node.value);
470
- if ((_a = result == null ? void 0 : result.groups) == null ? void 0 : _a.path) {
471
- const dest = path2.resolve(cwd, result[1]);
472
+ if (result) {
473
+ const dest = relative ? path2.resolve(cwd, path2.dirname(file.path), result[1]) : path2.resolve(cwd, result[1]);
472
474
  let value = fs.readFileSync(dest).toString();
473
475
  if (trim)
474
476
  value = value.trim();
@@ -9,6 +9,7 @@ import 'react';
9
9
  *
10
10
  * @param value - Blocks
11
11
  * @param slugFn - A function that generates slug from title
12
+ * @deprecated Sanity is no longer supported
12
13
  */
13
14
  declare function getTableOfContentsFromPortableText(value: any): TableOfContents;
14
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "10.1.0",
3
+ "version": "10.1.2",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -126,6 +126,7 @@
126
126
  },
127
127
  "devDependencies": {
128
128
  "@algolia/client-search": "^4.22.1",
129
+ "@mdx-js/mdx": "^3.0.1",
129
130
  "@types/flexsearch": "0.7.6",
130
131
  "@types/hast": "^3.0.4",
131
132
  "@types/mdast": "^4.0.3",