@void/md 1.2.1 → 1.4.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.
Files changed (2) hide show
  1. package/dist/plugin.mjs +16 -6
  2. package/package.json +4 -3
package/dist/plugin.mjs CHANGED
@@ -4,7 +4,7 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
4
4
  import { dirname, join, relative, resolve } from "pathslash";
5
5
  import { glob } from "tinyglobby";
6
6
  import { normalizePath } from "vite";
7
- import { resolvePagesDir } from "void/pages";
7
+ import { pageFileEnvironment, resolvePagesDir } from "void/pages";
8
8
  import { editIslandSource, findIslandImports } from "void/pages-islands-plugin";
9
9
  //#region src/emit-shared.ts
10
10
  const ISLAND_TAG_RE = /<([A-Z]\w*)\s*((?:[^>/"']|"[^"]*"|'[^']*')*)\/\s*>|<([A-Z]\w*)\s*((?:[^>/"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/\3\s*>/g;
@@ -299,6 +299,12 @@ const SOLID_VIRTUAL_PREFIX = "/@void-md-solid/";
299
299
  function stripPageSuffix(file) {
300
300
  return file.replace(/\.md$/, "").replace(/\/index$/, "").replace(/^index$/, "");
301
301
  }
302
+ function mdRouteName(file, env) {
303
+ let name = file.slice(0, -3);
304
+ if (env) name = name.slice(0, -("." + env).length);
305
+ if (name === "index") return "";
306
+ return name.endsWith("/index") ? name.slice(0, -6) : name;
307
+ }
302
308
  function hasMdFilesWithScript(dir) {
303
309
  try {
304
310
  for (const entry of readdirSync(dir, {
@@ -326,6 +332,7 @@ function voidMarkdown(options) {
326
332
  let mdPages = [];
327
333
  let root = "";
328
334
  let pagesDir = "";
335
+ let mdEnvironment = "prod";
329
336
  const svelteModules = /* @__PURE__ */ new Map();
330
337
  const solidModules = /* @__PURE__ */ new Map();
331
338
  const clientScripts = /* @__PURE__ */ new Map();
@@ -334,15 +341,17 @@ function voidMarkdown(options) {
334
341
  }
335
342
  async function scanMdPages() {
336
343
  if (!existsSync(pagesDir)) return [];
337
- const mdFiles = await glob("**/*.md", { cwd: pagesDir });
338
- return (await Promise.all(mdFiles.map(async (file) => {
344
+ const liveFiles = (await glob("**/*.md", { cwd: pagesDir })).filter((file) => {
345
+ const fileEnv = pageFileEnvironment(file);
346
+ return !fileEnv || fileEnv === mdEnvironment;
347
+ });
348
+ return (await Promise.all(liveFiles.map(async (file) => {
339
349
  const { body, clientCode } = extractScript(readFileSync(join(pagesDir, file), "utf-8"));
340
350
  const result = extractMetadata(body);
341
- const routeName = stripPageSuffix(file);
342
- const componentId = routeName || "index";
351
+ const componentId = stripPageSuffix(file) || "index";
343
352
  if (clientCode) clientScripts.set(componentId, clientCode);
344
353
  return {
345
- path: "/" + routeName,
354
+ path: "/" + mdRouteName(file, pageFileEnvironment(file)),
346
355
  title: result.title,
347
356
  frontmatter: result.frontmatter,
348
357
  headings: result.headings
@@ -359,6 +368,7 @@ function voidMarkdown(options) {
359
368
  }
360
369
  },
361
370
  config(config, env) {
371
+ mdEnvironment = env.command === "serve" && !env.isPreview ? "dev" : "prod";
362
372
  if (env.command === "serve") return;
363
373
  const configRoot = config.root || process.cwd();
364
374
  const pagesDir = resolvePagesDir(configRoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/md",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Markdown pages with layouts and interactive islands for Void.",
5
5
  "homepage": "https://void.cloud",
6
6
  "bugs": {
@@ -40,6 +40,7 @@
40
40
  "@shikijs/transformers": "^4.5.0",
41
41
  "gray-matter": "^4.0.3",
42
42
  "markdown-exit": "^1.3.0",
43
+ "markdown-it": "^15.0.3",
43
44
  "markdown-it-anchor": "^10.0.0",
44
45
  "markdown-it-attrs": "^5.0.1",
45
46
  "markdown-it-container": "^4.0.0",
@@ -53,11 +54,11 @@
53
54
  "@types/node": "^26.6.5",
54
55
  "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
55
56
  "vite-plus": "1.3.0",
56
- "void": "1.2.1"
57
+ "void": "1.4.0"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "vite": "^8.0.0",
60
- "void": "1.2.1"
61
+ "void": "1.4.0"
61
62
  },
62
63
  "scripts": {
63
64
  "build": "vp pack",