@vxrn/mdx 1.2.52 → 1.2.54
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/dist/index.js +15 -2
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +15 -2
- package/package.json +1 -1
- package/src/getAllFrontmatter.tsx +4 -1
- package/src/getMDXBySlug.tsx +2 -0
- package/src/index.ts +1 -0
- package/src/watchFile.ts +13 -0
- package/types/getAllFrontmatter.d.ts.map +1 -1
- package/types/getMDXBySlug.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/watchFile.d.ts +7 -0
- package/types/watchFile.d.ts.map +1 -0
package/dist/index.js
CHANGED
|
@@ -9700,6 +9700,7 @@ __export(index_exports, {
|
|
|
9700
9700
|
getAllVersionsFromPath: () => getAllVersionsFromPath,
|
|
9701
9701
|
getMDX: () => getMDX,
|
|
9702
9702
|
getMDXBySlug: () => getMDXBySlug,
|
|
9703
|
+
notifyFileRead: () => notifyFileRead,
|
|
9703
9704
|
rehypeHeroTemplate: () => rehypeHeroTemplate
|
|
9704
9705
|
});
|
|
9705
9706
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -9715,9 +9716,18 @@ var getTitle = (source) => source.replace(/^#+\s+/, "").replace(/<.*>/, " "), ge
|
|
|
9715
9716
|
id: getTitle(x).replace(/\s+/g, "-").toLowerCase()
|
|
9716
9717
|
}));
|
|
9717
9718
|
|
|
9719
|
+
// src/watchFile.ts
|
|
9720
|
+
var WATCH_FILE_KEY = "__oneWatchFile";
|
|
9721
|
+
function notifyFileRead(filePath) {
|
|
9722
|
+
let watchFile = globalThis[WATCH_FILE_KEY];
|
|
9723
|
+
watchFile && watchFile(filePath);
|
|
9724
|
+
}
|
|
9725
|
+
|
|
9718
9726
|
// src/getAllFrontmatter.tsx
|
|
9719
9727
|
var getAllFrontmatter = (fromPath) => import_fast_glob.default.sync(`${fromPath}/**/*.mdx`).map((filePath) => {
|
|
9720
|
-
let
|
|
9728
|
+
let absolutePath = import_node_path.default.join(filePath);
|
|
9729
|
+
notifyFileRead(absolutePath);
|
|
9730
|
+
let source = import_node_fs.default.readFileSync(absolutePath, "utf8"), { data, content } = (0, import_gray_matter.default)(source), slug2 = filePath.replace(`${fromPath.replaceAll("\\", "/")}/`, "").replace(".mdx", "");
|
|
9721
9731
|
return {
|
|
9722
9732
|
...data,
|
|
9723
9733
|
slug: slug2,
|
|
@@ -22398,7 +22408,9 @@ var getMDXBySlug = async (basePath, slug2, extraPlugins) => {
|
|
|
22398
22408
|
let versions = getAllVersionsFromPath(import_node_path2.default.join(basePath, slug2));
|
|
22399
22409
|
mdxPath += `/${versions[0]}`;
|
|
22400
22410
|
}
|
|
22401
|
-
let filePath = import_node_path2.default.join(basePath, `${mdxPath}.mdx`)
|
|
22411
|
+
let filePath = import_node_path2.default.join(basePath, `${mdxPath}.mdx`);
|
|
22412
|
+
notifyFileRead(filePath);
|
|
22413
|
+
let source = import_node_fs2.default.readFileSync(filePath, "utf8");
|
|
22402
22414
|
return await getMDX(source, extraPlugins);
|
|
22403
22415
|
};
|
|
22404
22416
|
function getAllVersionsFromPath(fromPath) {
|
|
@@ -22447,6 +22459,7 @@ var import_node_module = require("node:module"), import_node_fs3 = __toESM(requi
|
|
|
22447
22459
|
getAllVersionsFromPath,
|
|
22448
22460
|
getMDX,
|
|
22449
22461
|
getMDXBySlug,
|
|
22462
|
+
notifyFileRead,
|
|
22450
22463
|
rehypeHeroTemplate
|
|
22451
22464
|
});
|
|
22452
22465
|
/*! Bundled license information:
|