nuxt-content-assets 1.3.3 → 1.3.7
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 +24 -27
- package/dist/module.d.mts +29 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +52 -37
- package/dist/runtime/assets/public.d.ts +3 -2
- package/dist/runtime/assets/public.mjs +13 -7
- package/dist/runtime/assets/source.d.ts +2 -2
- package/dist/runtime/content/plugin.mjs +44 -43
- package/dist/runtime/sockets/factory.d.ts +1 -1
- package/dist/runtime/sockets/plugin.mjs +2 -2
- package/dist/runtime/sockets/setup.d.ts +1 -1
- package/dist/runtime/utils/content.d.ts +2 -2
- package/dist/types.d.mts +8 -0
- package/dist/types.d.ts +4 -2
- package/package.json +23 -21
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ To clone and run the demo locally:
|
|
|
70
70
|
```bash
|
|
71
71
|
git clone https://github.com/davestewart/nuxt-content-assets.git
|
|
72
72
|
cd nuxt-content-assets
|
|
73
|
-
npm install
|
|
73
|
+
npm install && npm install --prefix ./demo
|
|
74
74
|
npm run dev
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -205,7 +205,7 @@ See demo component [here](demo/components/content/ContentImage.vue).
|
|
|
205
205
|
|
|
206
206
|
### Nuxt Image compatibility
|
|
207
207
|
|
|
208
|
-
Nuxt Content Assets works with [Nuxt Image](https://
|
|
208
|
+
Nuxt Content Assets works with [Nuxt Image](https://image.nuxtjs.org/) with just a little configuration.
|
|
209
209
|
|
|
210
210
|
First, configure Nuxt Image to use Nuxt Content Asset's public folder:
|
|
211
211
|
|
|
@@ -318,13 +318,16 @@ In development, file watching propagates asset changes to the public folder, upd
|
|
|
318
318
|
|
|
319
319
|
Should you wish to develop the project, the scripts are:
|
|
320
320
|
|
|
321
|
-
Develop the module
|
|
321
|
+
Develop the module (running a demo which uses the live module code):
|
|
322
322
|
|
|
323
323
|
```bash
|
|
324
324
|
# install dependencies
|
|
325
325
|
npm install
|
|
326
326
|
|
|
327
|
-
#
|
|
327
|
+
# generate demo type stubs (for the first time)
|
|
328
|
+
npm run dev:prepare
|
|
329
|
+
|
|
330
|
+
# develop (runs the demo app)
|
|
328
331
|
npm run dev
|
|
329
332
|
|
|
330
333
|
# run eslint
|
|
@@ -335,23 +338,20 @@ npm run test
|
|
|
335
338
|
npm run test:watch
|
|
336
339
|
```
|
|
337
340
|
|
|
338
|
-
Build and check the demo:
|
|
341
|
+
Build and check the demo (simulating users' final build choices):
|
|
339
342
|
|
|
340
343
|
```bash
|
|
341
|
-
# generate demo
|
|
342
|
-
npm run
|
|
343
|
-
|
|
344
|
-
# generate the demo output
|
|
345
|
-
npm run demo:generate
|
|
346
|
-
|
|
347
|
-
# serve the demo output
|
|
348
|
-
npm run demo:serve
|
|
344
|
+
# generate the demo
|
|
345
|
+
npm run dev:generate
|
|
349
346
|
|
|
350
347
|
# build the demo
|
|
351
|
-
npm run
|
|
348
|
+
npm run dev:build
|
|
349
|
+
|
|
350
|
+
# serve the built demo
|
|
351
|
+
npm run dev:serve
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
-
Make a new release:
|
|
354
|
+
Make a new release (so users can install the module):
|
|
355
355
|
|
|
356
356
|
```bash
|
|
357
357
|
# release new version
|
|
@@ -361,24 +361,21 @@ npm run release
|
|
|
361
361
|
npm run release:dry
|
|
362
362
|
```
|
|
363
363
|
|
|
364
|
-
Make sure to edit changelog and update `package.json` version
|
|
364
|
+
Make sure to edit changelog and update `package.json` version before releasing!
|
|
365
365
|
|
|
366
|
-
##
|
|
366
|
+
## Maintenance
|
|
367
367
|
|
|
368
|
-
|
|
368
|
+
This module was created using the Nuxt [Module Builder](https://github.com/nuxt/module-builder) command:
|
|
369
369
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
If that's the case with you, fix Nuxt at `3.6.5` (if you can) and you should be fine.
|
|
370
|
+
```bash
|
|
371
|
+
npx nuxi init -t module nuxt-content-assets
|
|
372
|
+
```
|
|
375
373
|
|
|
376
|
-
|
|
374
|
+
This created the module code from the starter template found here:
|
|
377
375
|
|
|
378
|
-
- https://github.com/nuxt/
|
|
379
|
-
- https://github.com/davestewart/nuxt-content-assets/issues/49
|
|
376
|
+
- https://github.com/nuxt/starter/tree/module
|
|
380
377
|
|
|
381
|
-
|
|
378
|
+
Both [Nuxi](https://github.com/nuxt/cli) and the module's dependencies and scripts are updated fairly regularly, so from time to time this module will / does need to be updated to keep in sync. So far, this has meant just updating the dependencies and scripts, which are found in the starter template code mentioned above.
|
|
382
379
|
|
|
383
380
|
<!-- Badges -->
|
|
384
381
|
[npm-version-src]: https://img.shields.io/npm/v/nuxt-content-assets/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
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>;
|
|
28
|
+
|
|
29
|
+
export { _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import Fs from 'fs';
|
|
2
|
-
import
|
|
1
|
+
import * as Fs from 'fs';
|
|
2
|
+
import Fs__default from 'fs';
|
|
3
|
+
import * as Path from 'crosspath';
|
|
4
|
+
import Path__default from 'crosspath';
|
|
3
5
|
import { useNuxt, createResolver, defineNuxtModule, addPlugin } from '@nuxt/kit';
|
|
4
6
|
import { visit, SKIP, CONTINUE } from 'unist-util-visit';
|
|
5
7
|
import { listen } from 'listhen';
|
|
@@ -51,7 +53,7 @@ function isExcluded(path) {
|
|
|
51
53
|
return path.split("/").some((segment) => segment.startsWith(".") || segment.startsWith("_"));
|
|
52
54
|
}
|
|
53
55
|
function isImage(path) {
|
|
54
|
-
const ext =
|
|
56
|
+
const ext = Path__default.extname(path).substring(1);
|
|
55
57
|
return extensions.image.includes(ext);
|
|
56
58
|
}
|
|
57
59
|
function isArticle(path) {
|
|
@@ -153,33 +155,33 @@ function buildQuery(...expr) {
|
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
function readFile(path, asJson = false) {
|
|
156
|
-
const text =
|
|
158
|
+
const text = Fs__default.readFileSync(path, { encoding: "utf8" });
|
|
157
159
|
return asJson ? JSON.parse(text) : text;
|
|
158
160
|
}
|
|
159
161
|
function writeFile(path, data) {
|
|
160
162
|
const text = typeof data === "object" ? JSON.stringify(data, null, " ") : String(data);
|
|
161
|
-
createFolder(
|
|
162
|
-
|
|
163
|
+
createFolder(Path__default.dirname(path));
|
|
164
|
+
Fs__default.writeFileSync(path, text, { encoding: "utf8" });
|
|
163
165
|
}
|
|
164
166
|
async function writeBlob(path, data) {
|
|
165
167
|
const buffer = Buffer.from(await data.arrayBuffer());
|
|
166
|
-
createFolder(
|
|
167
|
-
|
|
168
|
+
createFolder(Path__default.dirname(path));
|
|
169
|
+
Fs__default.writeFileSync(path, buffer);
|
|
168
170
|
}
|
|
169
171
|
function copyFile(src, trg) {
|
|
170
|
-
createFolder(
|
|
171
|
-
|
|
172
|
+
createFolder(Path__default.dirname(trg));
|
|
173
|
+
Fs__default.copyFileSync(src, trg);
|
|
172
174
|
}
|
|
173
175
|
function removeFile(src) {
|
|
174
|
-
|
|
176
|
+
Fs__default.rmSync(src);
|
|
175
177
|
}
|
|
176
178
|
function createFolder(path) {
|
|
177
|
-
|
|
179
|
+
Fs__default.mkdirSync(path, { recursive: true });
|
|
178
180
|
}
|
|
179
181
|
function removeFolder(path) {
|
|
180
|
-
const isDownstream = path.startsWith(
|
|
182
|
+
const isDownstream = path.startsWith(Path__default.resolve());
|
|
181
183
|
if (isDownstream) {
|
|
182
|
-
|
|
184
|
+
Fs__default.rmSync(path, { recursive: true, force: true });
|
|
183
185
|
}
|
|
184
186
|
}
|
|
185
187
|
|
|
@@ -329,13 +331,13 @@ function makeSourceManager(key, source, publicPath, callback) {
|
|
|
329
331
|
return toPath(key2).replace(/\w+/, "").replace(source.prefix || "", "");
|
|
330
332
|
}
|
|
331
333
|
function getAbsSrc(key2) {
|
|
332
|
-
return
|
|
334
|
+
return Path__default.join(source.base, getRelSrc(key2));
|
|
333
335
|
}
|
|
334
336
|
function getRelTrg(key2) {
|
|
335
|
-
return
|
|
337
|
+
return Path__default.join(source.prefix || "", toPath(deKey(key2)));
|
|
336
338
|
}
|
|
337
339
|
function getAbsTrg(key2) {
|
|
338
|
-
return
|
|
340
|
+
return Path__default.join(publicPath, getRelTrg(key2));
|
|
339
341
|
}
|
|
340
342
|
function removeItem(key2) {
|
|
341
343
|
const absTrg = getAbsTrg(key2);
|
|
@@ -384,14 +386,16 @@ function makeSourceManager(key, source, publicPath, callback) {
|
|
|
384
386
|
};
|
|
385
387
|
}
|
|
386
388
|
|
|
387
|
-
function makeAssetsManager(publicPath) {
|
|
389
|
+
function makeAssetsManager(publicPath, shouldWatch = true) {
|
|
388
390
|
const indexKey = "assets.json";
|
|
389
|
-
const storage = makeSourceStorage(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
391
|
+
const storage = makeSourceStorage(Path__default.join(publicPath, ".."));
|
|
392
|
+
if (shouldWatch) {
|
|
393
|
+
void storage.watch(async (event, key) => {
|
|
394
|
+
if (event === "update" && key === indexKey) {
|
|
395
|
+
await load();
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
}
|
|
395
399
|
const assets = {};
|
|
396
400
|
async function load() {
|
|
397
401
|
const data = await storage.getItem(indexKey);
|
|
@@ -401,8 +405,8 @@ function makeAssetsManager(publicPath) {
|
|
|
401
405
|
void storage.setItem(indexKey, assets);
|
|
402
406
|
}, 50);
|
|
403
407
|
function resolveAsset(content, relAsset, registerContent = false) {
|
|
404
|
-
const srcDir =
|
|
405
|
-
const srcAsset =
|
|
408
|
+
const srcDir = Path__default.dirname(content._file);
|
|
409
|
+
const srcAsset = Path__default.join(srcDir, relAsset);
|
|
406
410
|
const asset = assets[srcAsset];
|
|
407
411
|
if (asset && registerContent) {
|
|
408
412
|
const { _id } = content;
|
|
@@ -445,11 +449,15 @@ function makeAssetsManager(publicPath) {
|
|
|
445
449
|
setAsset,
|
|
446
450
|
getAsset,
|
|
447
451
|
removeAsset,
|
|
448
|
-
resolveAsset
|
|
452
|
+
resolveAsset,
|
|
453
|
+
dispose: async () => {
|
|
454
|
+
await storage.unwatch();
|
|
455
|
+
await storage.dispose();
|
|
456
|
+
}
|
|
449
457
|
};
|
|
450
458
|
}
|
|
451
459
|
function getAssetPaths(srcDir, srcAbs) {
|
|
452
|
-
const srcRel =
|
|
460
|
+
const srcRel = Path__default.relative(srcDir, srcAbs);
|
|
453
461
|
const srcAttr = "/" + srcRel;
|
|
454
462
|
return {
|
|
455
463
|
srcRel,
|
|
@@ -515,7 +523,6 @@ const module = defineNuxtModule({
|
|
|
515
523
|
debug: false
|
|
516
524
|
},
|
|
517
525
|
async setup(options, nuxt) {
|
|
518
|
-
var _a, _b;
|
|
519
526
|
const buildPath = nuxt.options.buildDir;
|
|
520
527
|
const assetsPath = Path.join(buildPath, "content-assets");
|
|
521
528
|
const publicPath = Path.join(assetsPath, "public");
|
|
@@ -527,9 +534,9 @@ const module = defineNuxtModule({
|
|
|
527
534
|
removeFolder(assetsPath);
|
|
528
535
|
const { contentExtensions } = options;
|
|
529
536
|
if (contentExtensions) {
|
|
530
|
-
|
|
537
|
+
nuxt.options.content ||= {};
|
|
531
538
|
if (nuxt.options.content) {
|
|
532
|
-
|
|
539
|
+
nuxt.options.content.ignores ||= [];
|
|
533
540
|
}
|
|
534
541
|
const ignores = makeIgnores(contentExtensions);
|
|
535
542
|
nuxt.options.content?.ignores.push(ignores);
|
|
@@ -550,7 +557,8 @@ const module = defineNuxtModule({
|
|
|
550
557
|
};
|
|
551
558
|
}
|
|
552
559
|
}
|
|
553
|
-
const assets = makeAssetsManager(publicPath);
|
|
560
|
+
const assets = makeAssetsManager(publicPath, nuxt.options.dev);
|
|
561
|
+
nuxt.hooks.hook("close", () => assets.dispose());
|
|
554
562
|
function onAssetChange(event, absTrg) {
|
|
555
563
|
let src = "";
|
|
556
564
|
let width;
|
|
@@ -588,6 +596,12 @@ const module = defineNuxtModule({
|
|
|
588
596
|
}
|
|
589
597
|
managers[key] = makeSourceManager(key, source, publicPath, onAssetChange);
|
|
590
598
|
}
|
|
599
|
+
nuxt.hook("close", async () => {
|
|
600
|
+
for (const key in managers) {
|
|
601
|
+
await managers[key].storage.unwatch();
|
|
602
|
+
await managers[key].storage.dispose();
|
|
603
|
+
}
|
|
604
|
+
});
|
|
591
605
|
nuxt.hook("build:before", async function() {
|
|
592
606
|
for (const [key, manager] of Object.entries(managers)) {
|
|
593
607
|
const paths = await manager.init();
|
|
@@ -605,16 +619,17 @@ const module = defineNuxtModule({
|
|
|
605
619
|
makeVar("debug", options.debug)
|
|
606
620
|
].join("\n");
|
|
607
621
|
nuxt.hook("nitro:config", async (config) => {
|
|
608
|
-
config.plugins
|
|
622
|
+
config.plugins ||= [];
|
|
609
623
|
config.plugins.push(pluginPath);
|
|
610
|
-
config.virtual
|
|
624
|
+
config.virtual ||= {};
|
|
611
625
|
config.virtual[`#${meta.name}`] = () => {
|
|
612
626
|
return virtualConfig;
|
|
613
627
|
};
|
|
614
|
-
config.publicAssets
|
|
628
|
+
config.publicAssets ||= [];
|
|
615
629
|
config.publicAssets.push({
|
|
616
|
-
dir: publicPath
|
|
617
|
-
|
|
630
|
+
dir: publicPath,
|
|
631
|
+
maxAge: 60 * 60 * 24 * 7
|
|
632
|
+
// 7 days
|
|
618
633
|
});
|
|
619
634
|
});
|
|
620
635
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ParsedContent, AssetConfig } from '../../types';
|
|
1
|
+
import type { ParsedContent, AssetConfig } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Manages the public assets
|
|
4
4
|
*/
|
|
5
|
-
export declare function makeAssetsManager(publicPath: string): {
|
|
5
|
+
export declare function makeAssetsManager(publicPath: string, shouldWatch?: boolean): {
|
|
6
6
|
setAsset: (path: string) => AssetConfig;
|
|
7
7
|
getAsset: (path: string) => AssetConfig | undefined;
|
|
8
8
|
removeAsset: (path: string) => AssetConfig | undefined;
|
|
9
9
|
resolveAsset: (content: ParsedContent, relAsset: string, registerContent?: boolean) => AssetConfig;
|
|
10
|
+
dispose: () => Promise<void>;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
* Hash of replacer functions
|
|
@@ -4,14 +4,16 @@ import debounce from "debounce";
|
|
|
4
4
|
import { hash } from "ohash";
|
|
5
5
|
import { makeSourceStorage } from "./source.mjs";
|
|
6
6
|
import { isImage, warn, log } from "../utils/index.mjs";
|
|
7
|
-
export function makeAssetsManager(publicPath) {
|
|
7
|
+
export function makeAssetsManager(publicPath, shouldWatch = true) {
|
|
8
8
|
const indexKey = "assets.json";
|
|
9
9
|
const storage = makeSourceStorage(Path.join(publicPath, ".."));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
if (shouldWatch) {
|
|
11
|
+
void storage.watch(async (event, key) => {
|
|
12
|
+
if (event === "update" && key === indexKey) {
|
|
13
|
+
await load();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
15
17
|
const assets = {};
|
|
16
18
|
async function load() {
|
|
17
19
|
const data = await storage.getItem(indexKey);
|
|
@@ -65,7 +67,11 @@ export function makeAssetsManager(publicPath) {
|
|
|
65
67
|
setAsset,
|
|
66
68
|
getAsset,
|
|
67
69
|
removeAsset,
|
|
68
|
-
resolveAsset
|
|
70
|
+
resolveAsset,
|
|
71
|
+
dispose: async () => {
|
|
72
|
+
await storage.unwatch();
|
|
73
|
+
await storage.dispose();
|
|
74
|
+
}
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
77
|
export const replacers = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MountOptions } from '@nuxt/content';
|
|
2
|
-
import { WatchEvent, Storage } from 'unstorage';
|
|
1
|
+
import { type MountOptions } from '@nuxt/content';
|
|
2
|
+
import { type WatchEvent, type Storage } from 'unstorage';
|
|
3
3
|
/**
|
|
4
4
|
* Make a Storage instance that monitors assets from a single source
|
|
5
5
|
*/
|
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
import { buildQuery, buildStyle, isValidAsset, list, parseQuery, removeQuery, walkBody, walkMeta } from "../utils/index.mjs";
|
|
2
2
|
import { makeAssetsManager } from "../assets/public.mjs";
|
|
3
3
|
import { debug, imageSizes, publicPath } from "#nuxt-content-assets";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function processBody(content, imageSizes2 = [], updated = []) {
|
|
18
|
-
walkBody(content, function(node) {
|
|
19
|
-
const { tag, props } = node;
|
|
20
|
-
for (const [prop, value] of Object.entries(props)) {
|
|
21
|
-
if (typeof value !== "string") {
|
|
22
|
-
return;
|
|
4
|
+
const plugin = async (nitro) => {
|
|
5
|
+
function processMeta(content, imageSizes2 = [], updated = []) {
|
|
6
|
+
walkMeta(content, (value, parent, key) => {
|
|
7
|
+
if (isValidAsset(value)) {
|
|
8
|
+
const { srcAttr, width, height } = resolveAsset(content, removeQuery(value), true);
|
|
9
|
+
if (srcAttr) {
|
|
10
|
+
const query = width && height && (imageSizes2.includes("src") || imageSizes2.includes("url")) ? `width=${width}&height=${height}` : "";
|
|
11
|
+
const srcUrl = query ? buildQuery(srcAttr, parseQuery(value), query) : srcAttr;
|
|
12
|
+
parent[key] = srcUrl;
|
|
13
|
+
updated.push(`meta: ${key} to "${srcUrl}"`);
|
|
14
|
+
}
|
|
23
15
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
node.props.
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function processBody(content, imageSizes2 = [], updated = []) {
|
|
19
|
+
walkBody(content, function(node) {
|
|
20
|
+
const { tag, props } = node;
|
|
21
|
+
for (const [prop, value] of Object.entries(props)) {
|
|
22
|
+
if (typeof value !== "string") {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const { srcAttr, width, height } = resolveAsset(content, value, true);
|
|
26
|
+
if (srcAttr) {
|
|
27
|
+
node.props[prop] = srcAttr;
|
|
28
|
+
if (node.tag === "img" || node.tag === "nuxt-img") {
|
|
29
|
+
if (width && height) {
|
|
30
|
+
if (imageSizes2.includes("attrs")) {
|
|
31
|
+
node.props.width = width;
|
|
32
|
+
node.props.height = height;
|
|
33
|
+
}
|
|
34
|
+
if (imageSizes2.includes("style")) {
|
|
35
|
+
const ratio = `${width}/${height}`;
|
|
36
|
+
if (typeof node.props.style === "string") {
|
|
37
|
+
node.props.style = buildStyle(node.props.style, `aspect-ratio: ${ratio}`);
|
|
38
|
+
} else {
|
|
39
|
+
node.props.style ||= {};
|
|
40
|
+
node.props.style.aspectRatio = ratio;
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
}
|
|
44
|
+
} else if (node.tag === "a") {
|
|
45
|
+
node.props.target ||= "_blank";
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
node.props.target ||= "_blank";
|
|
47
|
+
updated.push(`page: ${tag}[${prop}] to "${srcAttr}"`);
|
|
45
48
|
}
|
|
46
|
-
updated.push(`page: ${tag}[${prop}] to "${srcAttr}"`);
|
|
47
49
|
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const { resolveAsset } = makeAssetsManager(publicPath);
|
|
52
|
-
const plugin = async (nitro) => {
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const { resolveAsset, dispose } = makeAssetsManager(publicPath, import.meta.dev);
|
|
53
53
|
nitro.hooks.hook("content:file:afterParse", function(content) {
|
|
54
54
|
if (content._extension === "md") {
|
|
55
55
|
const updated = [];
|
|
@@ -61,5 +61,6 @@ const plugin = async (nitro) => {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
+
nitro.hooks.hook("close", dispose);
|
|
64
65
|
};
|
|
65
66
|
export default plugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineNuxtPlugin, refreshNuxtData, useRuntimeConfig } from "#imports";
|
|
2
2
|
export default defineNuxtPlugin(async () => {
|
|
3
|
-
if (
|
|
3
|
+
if (import.meta.client) {
|
|
4
4
|
const url = useRuntimeConfig().public.sockets?.wsUrl;
|
|
5
|
-
const socket = await import("./setup").then(({ setupSocketClient }) => {
|
|
5
|
+
const socket = await import("./setup.mjs").then(({ setupSocketClient }) => {
|
|
6
6
|
return setupSocketClient(url, "content-assets");
|
|
7
7
|
});
|
|
8
8
|
if (socket) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Callback, SocketInstance } from '../../types';
|
|
1
|
+
import type { Callback, SocketInstance } from '../../types';
|
|
2
2
|
export declare function setupSocketClient(url: string, channel: string, callback?: Callback): SocketInstance | null;
|
package/dist/types.d.mts
ADDED
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-content-assets",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "Enable locally-located assets in Nuxt Content",
|
|
5
5
|
"repository": "davestewart/nuxt-content-assets",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,23 +19,22 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "nuxi dev demo",
|
|
22
|
-
"
|
|
22
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare demo",
|
|
23
|
+
"dev:generate": "nuxi generate demo",
|
|
24
|
+
"dev:build": "nuxi build demo",
|
|
25
|
+
"dev:serve": "npx serve demo/dist",
|
|
26
|
+
"release": "npm run lint && npm run test && nuxt-module-build build && changelogen --release && npm publish && git push --follow-tags",
|
|
27
|
+
"release:dry": "npm run lint && npm run test && nuxt-module-build build && npm publish --dry-run",
|
|
23
28
|
"lint": "eslint .",
|
|
24
29
|
"test": "vitest run",
|
|
25
|
-
"test:watch": "vitest watch"
|
|
26
|
-
"demo:prepare": "nuxt-module-build --stub && nuxi prepare demo",
|
|
27
|
-
"demo:generate": "nuxt generate demo",
|
|
28
|
-
"demo:serve": "npx serve demo/dist",
|
|
29
|
-
"demo:build": "nuxi build demo",
|
|
30
|
-
"release": "npm run lint && npm run test && npm run build && npm publish && git push --follow-tags",
|
|
31
|
-
"release:dry": "npm run lint && npm run test && npm run build && npm publish --dry-run"
|
|
30
|
+
"test:watch": "vitest watch"
|
|
32
31
|
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@nuxt/kit": "^3.
|
|
33
|
+
"@nuxt/kit": "^3.11.2",
|
|
35
34
|
"crosspath": "^2.0.0",
|
|
36
35
|
"debounce": "^1.2.1",
|
|
37
36
|
"image-size": "^1.0.2",
|
|
38
|
-
"listhen": "^1.
|
|
37
|
+
"listhen": "^1.7.2",
|
|
39
38
|
"ohash": "^1.0.0",
|
|
40
39
|
"unist-util-visit": "^4.1.2",
|
|
41
40
|
"unstorage": "^1.4.1",
|
|
@@ -45,17 +44,20 @@
|
|
|
45
44
|
"@nuxt/content": "^2.0.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@nuxt/
|
|
50
|
-
"@nuxt/
|
|
51
|
-
"@nuxt/
|
|
47
|
+
"@types/node": "^20.12.4",
|
|
48
|
+
"@nuxt/devtools": "latest",
|
|
49
|
+
"@nuxt/eslint-config": "^0.2.0",
|
|
50
|
+
"@nuxt/module-builder": "^0.5.5",
|
|
51
|
+
"@nuxt/schema": "^3.11.2",
|
|
52
|
+
"@nuxt/test-utils": "^3.12.0",
|
|
53
|
+
"changelogen": "^0.5.5",
|
|
54
|
+
"eslint": "^8.57.0",
|
|
55
|
+
"nuxt": "^3.11.2",
|
|
56
|
+
"vitest": "^1.4.0",
|
|
52
57
|
"@types/debounce": "^1.2.1",
|
|
53
|
-
"@types/ws": "^8.5.
|
|
54
|
-
"eslint": "^8.36.0",
|
|
55
|
-
"nuxt": "3.6.5",
|
|
56
|
-
"vitest": "^0.30.0"
|
|
58
|
+
"@types/ws": "^8.5.10"
|
|
57
59
|
},
|
|
58
60
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
61
|
+
"node": ">=16.0.0"
|
|
60
62
|
}
|
|
61
|
-
}
|
|
63
|
+
}
|