nuxt-content-assets 1.7.0 → 1.8.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/README.md +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/assets/public.d.ts +1 -1
- package/dist/runtime/assets/public.js +2 -2
- package/dist/runtime/assets/source.d.ts +1 -1
- package/dist/runtime/assets/source.js +13 -2
- package/dist/runtime/utils/path.d.ts +4 -0
- package/dist/runtime/utils/path.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -317,7 +317,7 @@ If you want to see what the module does as it runs, set `debug` to true:
|
|
|
317
317
|
|
|
318
318
|
## How it works
|
|
319
319
|
|
|
320
|
-
When Nuxt builds, the module scans all content sources for assets, copies them to a temporary layer folder (`
|
|
320
|
+
When Nuxt builds, the module scans all content sources for assets, copies them to a temporary layer folder (`node_modules/nuxt-content-assets/cache`), and indexes path and image metadata.
|
|
321
321
|
|
|
322
322
|
After Nuxt Content has run, the parsed content (`.nuxt/content-cache`) is traversed, and both element attributes and frontmatter properties are checked to see if they resolve to the previously-indexed asset paths.
|
|
323
323
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -221,7 +221,7 @@ const module$1 = defineNuxtModule({
|
|
|
221
221
|
nuxt.hook("close", async () => {
|
|
222
222
|
await assets.dispose();
|
|
223
223
|
for (const key in managers) {
|
|
224
|
-
await managers[key]
|
|
224
|
+
await managers[key]?.dispose();
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
227
|
const pluginPath = resolve("./runtime/content/plugin");
|
|
@@ -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,
|
|
7
|
+
import { isImage, log, removeEntry, removeOrdering, removeQuery, warn } 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, "..");
|
|
@@ -27,7 +27,7 @@ export function makeAssetsManager(publicPath, shouldWatch = true) {
|
|
|
27
27
|
function resolveAsset(content, relAsset, registerContent = false) {
|
|
28
28
|
const srcDir = Path.dirname(content._file);
|
|
29
29
|
const relAssetNoQuery = removeQuery(relAsset);
|
|
30
|
-
const srcAsset = Path.join(srcDir, relAssetNoQuery);
|
|
30
|
+
const srcAsset = removeOrdering(Path.join(srcDir, relAssetNoQuery));
|
|
31
31
|
const asset = assets[srcAsset];
|
|
32
32
|
if (asset && registerContent) {
|
|
33
33
|
const { _id } = content;
|
|
@@ -2,7 +2,18 @@ import Path from "crosspath";
|
|
|
2
2
|
import githubDriver from "unstorage/drivers/github";
|
|
3
3
|
import fsDriver from "unstorage/drivers/fs";
|
|
4
4
|
import { createStorage } from "unstorage";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
copyFile,
|
|
7
|
+
deKey,
|
|
8
|
+
isAsset,
|
|
9
|
+
isExcluded,
|
|
10
|
+
removeFile,
|
|
11
|
+
removeOrdering,
|
|
12
|
+
toPath,
|
|
13
|
+
warn,
|
|
14
|
+
writeBlob,
|
|
15
|
+
writeFile
|
|
16
|
+
} from "../utils/index.js";
|
|
6
17
|
function isAssetId(id) {
|
|
7
18
|
const path = toPath(id);
|
|
8
19
|
return !isExcluded(path) && isAsset(path);
|
|
@@ -46,7 +57,7 @@ export function makeSourceManager(key, source, publicPath, callback) {
|
|
|
46
57
|
return Path.join(source.base, getRelSrc(key2));
|
|
47
58
|
}
|
|
48
59
|
function getRelTrg(key2) {
|
|
49
|
-
return Path.join(source.prefix || "", toPath(deKey(key2)));
|
|
60
|
+
return Path.join(source.prefix || "", removeOrdering(toPath(deKey(key2))));
|
|
50
61
|
}
|
|
51
62
|
function getAbsTrg(key2) {
|
|
52
63
|
return Path.join(publicPath, getRelTrg(key2));
|
|
@@ -6,6 +6,10 @@ 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
|
+
* Remove ordering from a path
|
|
11
|
+
*/
|
|
12
|
+
export declare function removeOrdering(path: string): string;
|
|
9
13
|
/**
|
|
10
14
|
* Gets the extension of a path
|
|
11
15
|
* @param path
|
|
@@ -7,6 +7,9 @@ export function parseQuery(path) {
|
|
|
7
7
|
export function removeQuery(path) {
|
|
8
8
|
return path.replace(/\?.*$/, "");
|
|
9
9
|
}
|
|
10
|
+
export function removeOrdering(path) {
|
|
11
|
+
return path.split("/").map((segment) => segment.replace(/^\d+\./, "")).join("/");
|
|
12
|
+
}
|
|
10
13
|
export function getExt(path) {
|
|
11
14
|
return Path.extname(removeQuery(path)).substring(1);
|
|
12
15
|
}
|