nuxt-content-assets 1.3.0 → 1.3.2
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 +1 -1
- package/dist/module.mjs +7 -9
- package/dist/runtime/assets/public.mjs +3 -3
- package/dist/runtime/assets/source.mjs +1 -1
- package/dist/runtime/utils/config.d.ts +3 -0
- package/dist/runtime/utils/config.mjs +2 -3
- package/dist/runtime/utils/fs.mjs +2 -2
- package/dist/runtime/utils/path.mjs +1 -1
- package/package.json +3 -2
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import Path__default from 'path';
|
|
1
|
+
import Fs from 'fs';
|
|
2
|
+
import Path from 'crosspath';
|
|
4
3
|
import { useNuxt, createResolver, defineNuxtModule, addPlugin } from '@nuxt/kit';
|
|
5
4
|
import { visit, SKIP, CONTINUE } from 'unist-util-visit';
|
|
6
5
|
import { listen } from 'listhen';
|
|
@@ -41,9 +40,8 @@ const extensions = {
|
|
|
41
40
|
media: matchTokens("mp3 m4a wav mp4 mov webm ogg avi flv avchd")
|
|
42
41
|
};
|
|
43
42
|
function makeIgnores(extensions2) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
return `[^:]+\\.(?!(${ignored})$)`;
|
|
43
|
+
const included = matchTokens(extensions2).join("|");
|
|
44
|
+
return `^(?:(?!(${included})).)+$`;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
function removeQuery(path) {
|
|
@@ -53,7 +51,7 @@ function isExcluded(path) {
|
|
|
53
51
|
return path.split("/").some((segment) => segment.startsWith(".") || segment.startsWith("_"));
|
|
54
52
|
}
|
|
55
53
|
function isImage(path) {
|
|
56
|
-
const ext =
|
|
54
|
+
const ext = Path.extname(path).substring(1);
|
|
57
55
|
return extensions.image.includes(ext);
|
|
58
56
|
}
|
|
59
57
|
function isArticle(path) {
|
|
@@ -389,7 +387,7 @@ function makeSourceManager(key, source, publicPath, callback) {
|
|
|
389
387
|
function makeAssetsManager(publicPath) {
|
|
390
388
|
const indexKey = "assets.json";
|
|
391
389
|
const storage = makeSourceStorage(Path.join(publicPath, ".."));
|
|
392
|
-
storage.watch(async (event, key) => {
|
|
390
|
+
void storage.watch(async (event, key) => {
|
|
393
391
|
if (event === "update" && key === indexKey) {
|
|
394
392
|
await load();
|
|
395
393
|
}
|
|
@@ -400,7 +398,7 @@ function makeAssetsManager(publicPath) {
|
|
|
400
398
|
Object.assign(assets, data || {});
|
|
401
399
|
}
|
|
402
400
|
const save = debounce(function() {
|
|
403
|
-
storage.setItem(indexKey, assets);
|
|
401
|
+
void storage.setItem(indexKey, assets);
|
|
404
402
|
}, 50);
|
|
405
403
|
function resolveAsset(content, relAsset, registerContent = false) {
|
|
406
404
|
const srcDir = Path.dirname(content._file);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Path from "crosspath";
|
|
2
2
|
import getImageSize from "image-size";
|
|
3
3
|
import debounce from "debounce";
|
|
4
4
|
import { hash } from "ohash";
|
|
@@ -7,7 +7,7 @@ import { isImage, warn, log } from "../utils/index.mjs";
|
|
|
7
7
|
export function makeAssetsManager(publicPath) {
|
|
8
8
|
const indexKey = "assets.json";
|
|
9
9
|
const storage = makeSourceStorage(Path.join(publicPath, ".."));
|
|
10
|
-
storage.watch(async (event, key) => {
|
|
10
|
+
void storage.watch(async (event, key) => {
|
|
11
11
|
if (event === "update" && key === indexKey) {
|
|
12
12
|
await load();
|
|
13
13
|
}
|
|
@@ -18,7 +18,7 @@ export function makeAssetsManager(publicPath) {
|
|
|
18
18
|
Object.assign(assets, data || {});
|
|
19
19
|
}
|
|
20
20
|
const save = debounce(function() {
|
|
21
|
-
storage.setItem(indexKey, assets);
|
|
21
|
+
void storage.setItem(indexKey, assets);
|
|
22
22
|
}, 50);
|
|
23
23
|
function resolveAsset(content, relAsset, registerContent = false) {
|
|
24
24
|
const srcDir = Path.dirname(content._file);
|
|
@@ -7,5 +7,8 @@ export declare const extensions: {
|
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Create a Nuxt Content ignore string
|
|
10
|
+
*
|
|
11
|
+
* @see https://stackoverflow.com/questions/10052032/regex-pattern-that-does-not-match-certain-extensions
|
|
12
|
+
* @see https://regex101.com/r/gC3HXz/1
|
|
10
13
|
*/
|
|
11
14
|
export declare function makeIgnores(extensions: string | string[]): string;
|
|
@@ -6,7 +6,6 @@ export const extensions = {
|
|
|
6
6
|
media: matchTokens("mp3 m4a wav mp4 mov webm ogg avi flv avchd")
|
|
7
7
|
};
|
|
8
8
|
export function makeIgnores(extensions2) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
return `[^:]+\\.(?!(${ignored})$)`;
|
|
9
|
+
const included = matchTokens(extensions2).join("|");
|
|
10
|
+
return `^(?:(?!(${included})).)+$`;
|
|
12
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-content-assets",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Enable locally-located assets in Nuxt Content",
|
|
5
5
|
"repository": "davestewart/nuxt-content-assets",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@nuxt/kit": "^3.3.2",
|
|
35
|
+
"crosspath": "^2.0.0",
|
|
35
36
|
"debounce": "^1.2.1",
|
|
36
37
|
"image-size": "^1.0.2",
|
|
37
38
|
"listhen": "^1.0.4",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"ws": "^8.13.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"@nuxt/content": "
|
|
45
|
+
"@nuxt/content": "^2.0.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@nuxt/eslint-config": "^0.1.1",
|