@void/md 0.7.12 → 0.8.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.
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FrontmatterContext, setFrontmatter, useFrontmatter } from "./runtime/index.mjs";
|
|
2
|
-
import { n as MdPage } from "./plugin-
|
|
2
|
+
import { n as MdPage } from "./plugin-DYf54GZj.mjs";
|
|
3
3
|
export { FrontmatterContext, type MdPage, setFrontmatter, useFrontmatter };
|
|
@@ -50,6 +50,6 @@ type MdPage = Readonly<{
|
|
|
50
50
|
type MarkdownOptions = Readonly<{
|
|
51
51
|
shiki?: CompileOptions["shiki"];
|
|
52
52
|
}>;
|
|
53
|
-
declare function voidMarkdown(options?: MarkdownOptions):
|
|
53
|
+
declare function voidMarkdown(options?: MarkdownOptions): Array<Plugin>;
|
|
54
54
|
//#endregion
|
|
55
55
|
export { ScriptExtraction as a, IslandImport as i, MdPage as n, CompileOptions as o, voidMarkdown as r, CompileResult as s, MarkdownOptions as t };
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ScriptExtraction, i as IslandImport, n as MdPage, o as CompileOptions, r as voidMarkdown, s as CompileResult, t as MarkdownOptions } from "./plugin-
|
|
1
|
+
import { a as ScriptExtraction, i as IslandImport, n as MdPage, o as CompileOptions, r as voidMarkdown, s as CompileResult, t as MarkdownOptions } from "./plugin-DYf54GZj.mjs";
|
|
2
2
|
export { CompileOptions, CompileResult, IslandImport, MarkdownOptions, MdPage, ScriptExtraction, voidMarkdown };
|
package/dist/plugin.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from
|
|
|
3
3
|
import { dirname, join, relative, resolve } from "pathe";
|
|
4
4
|
import { glob } from "tinyglobby";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
|
+
import { resolvePagesDir } from "void/pages";
|
|
6
7
|
import matter from "gray-matter";
|
|
7
8
|
import MarkdownExit from "markdown-exit";
|
|
8
9
|
import anchor from "markdown-it-anchor";
|
|
@@ -496,6 +497,7 @@ function voidMarkdown(options) {
|
|
|
496
497
|
let adapter = null;
|
|
497
498
|
let mdPages = [];
|
|
498
499
|
let root = "";
|
|
500
|
+
let pagesDir = "";
|
|
499
501
|
const svelteModules = /* @__PURE__ */ new Map();
|
|
500
502
|
const solidModules = /* @__PURE__ */ new Map();
|
|
501
503
|
const clientScripts = /* @__PURE__ */ new Map();
|
|
@@ -503,7 +505,6 @@ function voidMarkdown(options) {
|
|
|
503
505
|
return `${prefix}${Buffer.from(importerId).toString("base64url")}.${createHash("sha1").update(source).digest("hex").slice(0, 8)}.${extension}`;
|
|
504
506
|
}
|
|
505
507
|
async function scanMdPages() {
|
|
506
|
-
const pagesDir = join(root, "pages");
|
|
507
508
|
if (!existsSync(pagesDir)) return [];
|
|
508
509
|
const mdFiles = await glob("**/*.md", { cwd: pagesDir });
|
|
509
510
|
return (await Promise.all(mdFiles.map(async (file) => {
|
|
@@ -538,12 +539,13 @@ function voidMarkdown(options) {
|
|
|
538
539
|
},
|
|
539
540
|
config(config, env) {
|
|
540
541
|
if (env.command === "serve") return;
|
|
541
|
-
const pagesDir =
|
|
542
|
+
const pagesDir = resolvePagesDir(config.root || process.cwd());
|
|
542
543
|
if (!existsSync(pagesDir)) return;
|
|
543
544
|
if (hasMdFilesWithScript(pagesDir) && hasIslandFiles(pagesDir)) return { environments: { client: { build: { rollupOptions: { input: { "md-client": MD_CLIENT_ENTRY_ID } } } } } };
|
|
544
545
|
},
|
|
545
546
|
configResolved(config) {
|
|
546
547
|
root = config.root;
|
|
548
|
+
pagesDir = resolvePagesDir(root);
|
|
547
549
|
for (const plugin of config.plugins) {
|
|
548
550
|
const match = ADAPTER_PLUGIN_NAMES[plugin.name];
|
|
549
551
|
if (match) {
|
|
@@ -561,8 +563,10 @@ function voidMarkdown(options) {
|
|
|
561
563
|
writeMdTypes();
|
|
562
564
|
},
|
|
563
565
|
configureServer(server) {
|
|
566
|
+
const normalizedPagesDir = normalizePath(pagesDir);
|
|
567
|
+
const isInPagesDir = (file) => file === normalizedPagesDir || file.startsWith(normalizedPagesDir + "/");
|
|
564
568
|
const handleMdChange = async (file) => {
|
|
565
|
-
if (!file.endsWith(".md") || !file
|
|
569
|
+
if (!file.endsWith(".md") || !isInPagesDir(normalizePath(file))) return;
|
|
566
570
|
mdPages = await scanMdPages();
|
|
567
571
|
const mod = server.moduleGraph.getModuleById("\0void-md-pages");
|
|
568
572
|
if (mod) server.moduleGraph.invalidateModule(mod);
|
|
@@ -637,7 +641,7 @@ export function useFrontmatter() { return useContext(FrontmatterContext) ?? {};
|
|
|
637
641
|
filter: { id: /\.md$/ },
|
|
638
642
|
async handler(code, _id) {
|
|
639
643
|
const { body, islandImports, clientCode } = extractScript(code);
|
|
640
|
-
const pagesPrefix =
|
|
644
|
+
const pagesPrefix = pagesDir + "/";
|
|
641
645
|
if (_id.startsWith(pagesPrefix) && clientCode) {
|
|
642
646
|
const componentId = _id.slice(pagesPrefix.length).replace(/\.md$/, "").replace(/\/index$/, "").replace(/^index$/, "") || "index";
|
|
643
647
|
clientScripts.set(componentId, clientCode);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/md",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/voidzero-dev/void.git",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
|
|
52
52
|
"vite-plus": "^0.1.20",
|
|
53
53
|
"vue": "^3.5.34",
|
|
54
|
-
"void": "0.
|
|
54
|
+
"void": "0.8.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"vite": "^8.0.0",
|
|
58
|
-
"void": "0.
|
|
58
|
+
"void": "0.8.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "vp pack",
|