nuxt-content-assets 1.4.3 → 1.4.4

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/README.md CHANGED
@@ -249,7 +249,7 @@ export default defineNuxtConfig({
249
249
  imageSize: 'style',
250
250
 
251
251
  // treat these extensions as content
252
- contentExtensions: 'md csv ya?ml json',
252
+ contentExtensions: 'mdx? csv ya?ml json',
253
253
 
254
254
  // output debug messages
255
255
  debug: false,
@@ -259,6 +259,10 @@ export default defineNuxtConfig({
259
259
 
260
260
  ### Image size
261
261
 
262
+ > [!Note]
263
+ >
264
+ > Since `v1.4.1` image size hints are now opt-in. This was done to maximise compatibiility with Nuxt Image.
265
+
262
266
  You can add one _or more_ image size hints to the generated images:
263
267
 
264
268
  ```ts
@@ -284,22 +288,22 @@ img {
284
288
  }
285
289
  ```
286
290
 
287
- > [!Note]
288
- >
289
- > Since `v1.4.1` image size hints are now opt-in. This was done to maximise compatibiility with Nuxt Image.
290
-
291
291
  ### Content extensions
292
292
 
293
293
  > [!NOTE]
294
294
  > Generally, you shouldn't need to touch this setting
295
295
 
296
- This setting tells Nuxt Content to ignore anything that is **not** one of these file extensions:
296
+ This setting tells Nuxt Content to ignore anything that is **not** one of the supported content types:
297
297
 
298
298
  ```
299
- md csv ya?ml json
299
+ mdx? csv ya?ml json
300
300
  ```
301
301
 
302
- This way, you can use any **other** file type as an asset, without needing to explicitly configure extensions.
302
+ This way, you can use any **other** file type as an asset, without needing to explicitly configure Nuxt Content's [ignores](https://content.nuxt.com/get-started/configuration#ignores) list.
303
+
304
+ Without this, Nuxt Content would warn about unsupported file types:
305
+
306
+ > [WARN] .jpg files are not supported, "content:path:to:some-asset.jpg" falling back to raw content
303
307
 
304
308
  ### Debug
305
309
 
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "1.4.3"
7
+ "version": "1.4.4"
8
8
  }
package/dist/module.mjs CHANGED
@@ -37,6 +37,8 @@ function deKey(path) {
37
37
  const extensions = {
38
38
  // used to get image size
39
39
  image: matchTokens("png jpg jpeg gif svg webp ico"),
40
+ // used to recognise content
41
+ content: matchTokens("md mdx json yml yaml csv"),
40
42
  // unused for now
41
43
  media: matchTokens("mp3 m4a wav mp4 mov webm ogg avi flv avchd")
42
44
  };
@@ -48,15 +50,17 @@ function makeIgnores(extensions2) {
48
50
  function removeQuery(path) {
49
51
  return path.replace(/\?.*$/, "");
50
52
  }
53
+ function getExt(path) {
54
+ return Path.extname(removeQuery(path)).substring(1);
55
+ }
51
56
  function isExcluded(path) {
52
57
  return path.split("/").some((segment) => segment.startsWith(".") || segment.startsWith("_"));
53
58
  }
54
59
  function isImage(path) {
55
- const ext = Path.extname(path).substring(1);
56
- return extensions.image.includes(ext);
60
+ return extensions.image.includes(getExt(path));
57
61
  }
58
62
  function isArticle(path) {
59
- return removeQuery(path).endsWith(".md");
63
+ return extensions.content.includes(getExt(path));
60
64
  }
61
65
  function isAsset(path) {
62
66
  return !isArticle(path);
@@ -547,7 +551,7 @@ const module = defineNuxtModule({
547
551
  meta,
548
552
  defaults: {
549
553
  imageSize: "",
550
- contentExtensions: "md csv ya?ml json",
554
+ contentExtensions: "mdx? csv ya?ml json",
551
555
  debug: false
552
556
  },
553
557
  async setup(options, nuxt) {
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export declare const extensions: {
5
5
  image: string[];
6
+ content: string[];
6
7
  media: string[];
7
8
  };
8
9
  /**
@@ -2,6 +2,8 @@ import { matchTokens } from "./string.mjs";
2
2
  export const extensions = {
3
3
  // used to get image size
4
4
  image: matchTokens("png jpg jpeg gif svg webp ico"),
5
+ // used to recognise content
6
+ content: matchTokens("md mdx json yml yaml csv"),
5
7
  // unused for now
6
8
  media: matchTokens("mp3 m4a wav mp4 mov webm ogg avi flv avchd")
7
9
  };
@@ -6,6 +6,11 @@ export declare function parseQuery(path: string): string;
6
6
  * Removes the query string from a path
7
7
  */
8
8
  export declare function removeQuery(path: string): string;
9
+ /**
10
+ * Gets the extension of a path
11
+ * @param path
12
+ */
13
+ export declare function getExt(path: string): string;
9
14
  /**
10
15
  * Test path to be relative
11
16
  */
@@ -20,7 +25,7 @@ export declare function isExcluded(path: string): boolean;
20
25
  */
21
26
  export declare function isImage(path: string): boolean;
22
27
  /**
23
- * Test path is markdown
28
+ * Test path is markdown or data
24
29
  */
25
30
  export declare function isArticle(path: string): boolean;
26
31
  /**
@@ -7,6 +7,9 @@ export function parseQuery(path) {
7
7
  export function removeQuery(path) {
8
8
  return path.replace(/\?.*$/, "");
9
9
  }
10
+ export function getExt(path) {
11
+ return Path.extname(removeQuery(path)).substring(1);
12
+ }
10
13
  export function isRelative(path) {
11
14
  return !(path.startsWith("http") || Path.isAbsolute(path));
12
15
  }
@@ -14,11 +17,10 @@ export function isExcluded(path) {
14
17
  return path.split("/").some((segment) => segment.startsWith(".") || segment.startsWith("_"));
15
18
  }
16
19
  export function isImage(path) {
17
- const ext = Path.extname(path).substring(1);
18
- return extensions.image.includes(ext);
20
+ return extensions.image.includes(getExt(path));
19
21
  }
20
22
  export function isArticle(path) {
21
- return removeQuery(path).endsWith(".md");
23
+ return extensions.content.includes(getExt(path));
22
24
  }
23
25
  export function isAsset(path) {
24
26
  return !isArticle(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-content-assets",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Enable locally-located assets in Nuxt Content",
5
5
  "repository": "davestewart/nuxt-content-assets",
6
6
  "license": "MIT",