nuxt-content-assets 1.5.2 → 1.7.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.
package/dist/module.d.mts
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface ModuleOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Image size hints
|
|
6
|
-
*
|
|
7
|
-
* @example 'attrs style url'
|
|
8
|
-
* @default 'style'
|
|
9
|
-
*/
|
|
10
|
-
imageSize?: string | string[] | false;
|
|
11
|
-
/**
|
|
12
|
-
* List of content extensions; anything else as an asset
|
|
13
|
-
*
|
|
14
|
-
* @example 'md'
|
|
15
|
-
* @default 'md csv ya?ml json'
|
|
16
|
-
*/
|
|
17
|
-
contentExtensions?: string | string[];
|
|
18
|
-
/**
|
|
19
|
-
* Display debug messages
|
|
20
|
-
*
|
|
21
|
-
* @example true
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
debug?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
1
|
+
declare const _default: any;
|
|
28
2
|
|
|
29
3
|
export { _default as default };
|
package/dist/module.json
CHANGED
|
@@ -7,7 +7,7 @@ export declare function makeAssetsManager(publicPath: string, shouldWatch?: bool
|
|
|
7
7
|
setAsset: (path: string) => AssetConfig;
|
|
8
8
|
getAsset: (path: string) => AssetConfig | undefined;
|
|
9
9
|
removeAsset: (path: string) => AssetConfig | undefined;
|
|
10
|
-
resolveAsset: (content: ParsedContent, relAsset: string, registerContent?: boolean) =>
|
|
10
|
+
resolveAsset: (content: ParsedContent, relAsset: string, registerContent?: boolean) => AssetConfig;
|
|
11
11
|
dispose: () => Promise<void>;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -4,7 +4,7 @@ import getImageSize from "image-size";
|
|
|
4
4
|
import debounce from "debounce";
|
|
5
5
|
import { hash } from "ohash";
|
|
6
6
|
import { makeSourceStorage } from "./source.js";
|
|
7
|
-
import { isImage, warn, log, removeEntry } from "../utils/index.js";
|
|
7
|
+
import { isImage, warn, log, removeEntry, removeQuery } from "../utils/index.js";
|
|
8
8
|
export function makeAssetsManager(publicPath, shouldWatch = true) {
|
|
9
9
|
const assetsKey = "assets.json";
|
|
10
10
|
const assetsPath = Path.join(publicPath, "..");
|
|
@@ -26,7 +26,8 @@ export function makeAssetsManager(publicPath, shouldWatch = true) {
|
|
|
26
26
|
}, 50);
|
|
27
27
|
function resolveAsset(content, relAsset, registerContent = false) {
|
|
28
28
|
const srcDir = Path.dirname(content._file);
|
|
29
|
-
const
|
|
29
|
+
const relAssetNoQuery = removeQuery(relAsset);
|
|
30
|
+
const srcAsset = Path.join(srcDir, relAssetNoQuery);
|
|
30
31
|
const asset = assets[srcAsset];
|
|
31
32
|
if (asset && registerContent) {
|
|
32
33
|
const { _id } = content;
|
|
@@ -35,7 +36,16 @@ export function makeAssetsManager(publicPath, shouldWatch = true) {
|
|
|
35
36
|
save();
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
if (asset) {
|
|
40
|
+
if (relAsset.includes("?")) {
|
|
41
|
+
return {
|
|
42
|
+
...asset,
|
|
43
|
+
srcAttr: asset.srcAttr + "?" + relAsset.split("?").pop() || ""
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return asset;
|
|
47
|
+
}
|
|
48
|
+
return { srcAttr: "", content: [] };
|
|
39
49
|
}
|
|
40
50
|
function setAsset(path) {
|
|
41
51
|
const { srcRel, srcAttr } = getAssetPaths(publicPath, path);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { matchTokens } from "./string.js";
|
|
2
2
|
export const extensions = {
|
|
3
|
-
// used to get image size
|
|
4
|
-
image: matchTokens("png jpg jpeg gif svg webp ico"),
|
|
5
3
|
// used to recognise content
|
|
6
4
|
content: matchTokens("md mdx json yml yaml csv"),
|
|
5
|
+
// used to get image size
|
|
6
|
+
image: matchTokens("png jpg jpeg gif svg webp ico avif bmp cur"),
|
|
7
7
|
// unused for now
|
|
8
8
|
media: matchTokens("mp3 m4a wav mp4 mov webm ogg avi flv avchd")
|
|
9
9
|
};
|