@theholocron/docs-theme 1.2.0 → 1.2.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.
- package/dist/loader.mjs +13 -5
- package/package.json +1 -1
package/dist/loader.mjs
CHANGED
|
@@ -20,10 +20,18 @@ function computeId(filePath, baseDir, slugPrefix) {
|
|
|
20
20
|
return slugPrefix || "index";
|
|
21
21
|
}
|
|
22
22
|
function resolvePackageContentDir(packageName, root) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
dir
|
|
23
|
+
const req = createRequire(root);
|
|
24
|
+
try {
|
|
25
|
+
let dir = dirname(req.resolve(packageName));
|
|
26
|
+
while (dir !== dirname(dir)) {
|
|
27
|
+
if (existsSync(join(dir, "package.json"))) return join(dir, "content");
|
|
28
|
+
dir = dirname(dir);
|
|
29
|
+
}
|
|
30
|
+
} catch {}
|
|
31
|
+
const parts = packageName.startsWith("@") ? packageName.split("/", 2) : [packageName];
|
|
32
|
+
for (const searchPath of req.resolve.paths(packageName) ?? []) {
|
|
33
|
+
const candidate = join(searchPath, ...parts);
|
|
34
|
+
if (existsSync(join(candidate, "package.json"))) return join(candidate, "content");
|
|
27
35
|
}
|
|
28
36
|
throw new Error(`Could not resolve content directory for ${packageName}`);
|
|
29
37
|
}
|
|
@@ -64,7 +72,7 @@ function createDocsLoader(sources) {
|
|
|
64
72
|
const raw = await readFile(absPath, "utf-8");
|
|
65
73
|
const { data: frontmatter, content: body } = matter(raw);
|
|
66
74
|
const digest = ctx.generateDigest(raw);
|
|
67
|
-
const filePath = relative(siteRoot, absPath);
|
|
75
|
+
const filePath = absPath.includes("node_modules") ? id + extname(absPath) : relative(siteRoot, absPath);
|
|
68
76
|
const data = await ctx.parseData({
|
|
69
77
|
id,
|
|
70
78
|
data: frontmatter,
|