@zikojs/vite-plugin-mdx 0.3.0 → 0.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/package.json +1 -1
  2. package/src/index.js +14 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zikojs/vite-plugin-mdx",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Vite plugin for Zikojs MDX support",
5
5
  "keywords": [
6
6
  "zikojs",
package/src/index.js CHANGED
@@ -1,18 +1,25 @@
1
+ import { createFilter } from "vite";
1
2
  import { transpileMD } from "@zikojs/mdx";
2
3
 
3
4
  export default function ViteMDX({
4
5
  plugins,
5
6
  syntaxHighlightAdapter = null,
6
- marker = ''
7
+ marker = "",
8
+ include = ["**/*"],
7
9
  } = {}) {
8
10
  const extensions = [".mdx", ".md"];
9
11
 
10
- const isMarkdownFile = (id) =>
11
- extensions.some((ext) =>
12
+ const includeFilter = createFilter(include);
13
+
14
+ const isMarkdownFile = (id) => {
15
+ if (!includeFilter(id)) return false;
16
+
17
+ return extensions.some((ext) =>
12
18
  marker
13
19
  ? id.endsWith(`${marker}${ext}`)
14
20
  : id.endsWith(ext)
15
21
  );
22
+ };
16
23
 
17
24
  return {
18
25
  name: "@zikojs/vite-plugin-mdx",
@@ -22,12 +29,12 @@ export default function ViteMDX({
22
29
 
23
30
  const code = await transpileMD(src, {
24
31
  plugins,
25
- syntaxHighlightAdapter
32
+ syntaxHighlightAdapter,
26
33
  });
27
34
 
28
35
  return {
29
36
  code,
30
- map: null
37
+ map: null,
31
38
  };
32
39
  },
33
40
 
@@ -35,7 +42,7 @@ export default function ViteMDX({
35
42
  if (!isMarkdownFile(file)) return;
36
43
 
37
44
  server.ws.send({
38
- type: "full-reload"
45
+ type: "full-reload",
39
46
  });
40
47
 
41
48
  // server.ws.send({
@@ -48,6 +55,6 @@ export default function ViteMDX({
48
55
  // });
49
56
 
50
57
  return [file];
51
- }
58
+ },
52
59
  };
53
60
  }