nuxt-content-assets 0.10.0 → 0.10.1

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/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.10.0"
7
+ "version": "0.10.1"
8
8
  }
package/dist/module.mjs CHANGED
@@ -28,7 +28,7 @@ const defaults = {
28
28
  // inject image size into the rendered html
29
29
  imageSize: "attrs",
30
30
  // treat these extensions as content
31
- contentExtensions: "mdx? csv ya?ml json",
31
+ contentExtensions: "md csv ya?ml json",
32
32
  // output debug messages
33
33
  debug: false
34
34
  };
@@ -42,16 +42,18 @@ function getIgnores(extensions2) {
42
42
  return `^((?!(${matchTokens(extensions2).join("|")})).)*$`;
43
43
  }
44
44
 
45
+ function isExcluded(path) {
46
+ return path.split("/").some((segment) => segment.startsWith(".") || segment.startsWith("_"));
47
+ }
45
48
  function isImage(path) {
46
49
  const ext = Path__default.extname(path).substring(1);
47
50
  return extensions.image.includes(ext);
48
51
  }
49
52
  function isArticle(path) {
50
- return /\.mdx?$/.test(path);
53
+ return path.endsWith(".md");
51
54
  }
52
55
  function isAsset(path) {
53
- const ext = Path__default.extname(path);
54
- return !!ext && ext !== ".DS_Store" && !isArticle(path);
56
+ return !isExcluded(path) && !isArticle(path);
55
57
  }
56
58
 
57
59
  const moduleName = "nuxt-content-assets";
@@ -144,7 +146,10 @@ function makeStorage(source, key = "") {
144
146
  case "fs":
145
147
  storage.mount(key, fsDriver({
146
148
  ...options,
147
- ignore: ["[^:]+?\\.md"]
149
+ ignore: [
150
+ "[^:]+?\\.md",
151
+ "_dir\\.yml"
152
+ ]
148
153
  }));
149
154
  break;
150
155
  case "github":
@@ -159,7 +164,7 @@ function makeStorage(source, key = "") {
159
164
  }
160
165
  function makeSourceManager(key, source, publicPath, callback) {
161
166
  async function onWatch(event, key2) {
162
- if (isAsset(key2)) {
167
+ if (isAsset(toPath(key2))) {
163
168
  const path = event === "update" ? await copyItem(key2) : removeItem(key2);
164
169
  if (callback) {
165
170
  callback(event, path);
@@ -205,7 +210,7 @@ function makeSourceManager(key, source, publicPath, callback) {
205
210
  }
206
211
  async function getKeys() {
207
212
  const keys = await storage.getKeys();
208
- return keys.filter(isAsset);
213
+ return keys.map(toPath).filter(isAsset);
209
214
  }
210
215
  async function init() {
211
216
  const keys = await getKeys();
@@ -3,7 +3,7 @@ export const defaults = {
3
3
  // inject image size into the rendered html
4
4
  imageSize: "attrs",
5
5
  // treat these extensions as content
6
- contentExtensions: "mdx? csv ya?ml json",
6
+ contentExtensions: "md csv ya?ml json",
7
7
  // output debug messages
8
8
  debug: false
9
9
  };
@@ -10,7 +10,10 @@ export function makeStorage(source, key = "") {
10
10
  case "fs":
11
11
  storage.mount(key, fsDriver({
12
12
  ...options,
13
- ignore: ["[^:]+?\\.md"]
13
+ ignore: [
14
+ "[^:]+?\\.md",
15
+ "_dir\\.yml"
16
+ ]
14
17
  }));
15
18
  break;
16
19
  case "github":
@@ -25,7 +28,7 @@ export function makeStorage(source, key = "") {
25
28
  }
26
29
  export function makeSourceManager(key, source, publicPath, callback) {
27
30
  async function onWatch(event, key2) {
28
- if (isAsset(key2)) {
31
+ if (isAsset(toPath(key2))) {
29
32
  const path = event === "update" ? await copyItem(key2) : removeItem(key2);
30
33
  if (callback) {
31
34
  callback(event, path);
@@ -71,7 +74,7 @@ export function makeSourceManager(key, source, publicPath, callback) {
71
74
  }
72
75
  async function getKeys() {
73
76
  const keys = await storage.getKeys();
74
- return keys.filter(isAsset);
77
+ return keys.map(toPath).filter(isAsset);
75
78
  }
76
79
  async function init() {
77
80
  const keys = await getKeys();
@@ -3,15 +3,20 @@
3
3
  */
4
4
  export declare function isRelative(path: string): boolean;
5
5
  /**
6
- * Test path or id for image extension
6
+ * Test if path is excluded (_partial or .ignored)
7
+ * @param path
8
+ */
9
+ export declare function isExcluded(path: string): boolean;
10
+ /**
11
+ * Test path for image extension
7
12
  */
8
13
  export declare function isImage(path: string): boolean;
9
14
  /**
10
- * Test path or id is markdown
15
+ * Test path is markdown
11
16
  */
12
17
  export declare function isArticle(path: string): boolean;
13
18
  /**
14
- * Test path or id is asset
19
+ * Test path is asset
15
20
  */
16
21
  export declare function isAsset(path: string): boolean;
17
22
  /**
@@ -3,16 +3,18 @@ import { extensions } from "../options.mjs";
3
3
  export function isRelative(path) {
4
4
  return !(path.startsWith("http") || Path.isAbsolute(path));
5
5
  }
6
+ export function isExcluded(path) {
7
+ return path.split("/").some((segment) => segment.startsWith(".") || segment.startsWith("_"));
8
+ }
6
9
  export function isImage(path) {
7
10
  const ext = Path.extname(path).substring(1);
8
11
  return extensions.image.includes(ext);
9
12
  }
10
13
  export function isArticle(path) {
11
- return /\.mdx?$/.test(path);
14
+ return path.endsWith(".md");
12
15
  }
13
16
  export function isAsset(path) {
14
- const ext = Path.extname(path);
15
- return !!ext && ext !== ".DS_Store" && !isArticle(path);
17
+ return !isExcluded(path) && !isArticle(path);
16
18
  }
17
19
  export function isValidAsset(value) {
18
20
  return typeof value === "string" && isAsset(value) && isRelative(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-content-assets",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Enable locally-located assets in Nuxt Content",
5
5
  "repository": "davestewart/nuxt-content-assets",
6
6
  "license": "MIT",