nuxt-content-assets 0.6.0 → 0.6.1
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 +40 -19
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -2
- package/dist/runtime/config.d.ts +2 -0
- package/dist/runtime/config.mjs +2 -0
- package/dist/runtime/plugin.d.ts +3 -2
- package/dist/runtime/plugin.mjs +4 -3
- package/dist/runtime/utils/debug.mjs +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -47,7 +47,13 @@ That's it!
|
|
|
47
47
|
|
|
48
48
|
## Demo
|
|
49
49
|
|
|
50
|
-
To
|
|
50
|
+
To view the demo locally, run:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
npm run dev
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To view the demo online, visit:
|
|
51
57
|
|
|
52
58
|
- https://stackblitz.com/github/davestewart/nuxt-content-assets?file=demo%2Fapp.vue
|
|
53
59
|
|
|
@@ -55,12 +61,6 @@ You can browse the demo files in:
|
|
|
55
61
|
|
|
56
62
|
- https://github.com/davestewart/nuxt-content-assets/tree/main/demo
|
|
57
63
|
|
|
58
|
-
To run the demo locally, clone the application and from the root, run:
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
npm run demo
|
|
62
|
-
```
|
|
63
|
-
|
|
64
64
|
## Setup
|
|
65
65
|
|
|
66
66
|
Install the dependency:
|
|
@@ -132,7 +132,7 @@ Then pass these to components like so:
|
|
|
132
132
|
::
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
> Note: to pass size hints in frontmatter, set the `imageSize` configuration option to `'url'`
|
|
135
|
+
> Note: to pass size hints in frontmatter, set the `imageSize` configuration [option](#image-size) to `'url'`
|
|
136
136
|
|
|
137
137
|
See the [Demo](demo/content/recipes/index.md) for an example.
|
|
138
138
|
|
|
@@ -156,7 +156,7 @@ The module can prevent content jumps by optionally writing image size informatio
|
|
|
156
156
|
<img src="/image.jpg?width=640&height=480" width="640" height="480" style="aspect-ratio:640/480">
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
If you use
|
|
159
|
+
If you use [ProseImg](https://content.nuxtjs.org/api/components/prose) components, you can pass these values to your own markup:
|
|
160
160
|
|
|
161
161
|
```vue
|
|
162
162
|
<template>
|
|
@@ -172,7 +172,7 @@ export default {
|
|
|
172
172
|
</script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
See the [configuration](#image-size) section to add this, and the [Demo](demo/components/
|
|
175
|
+
See the [configuration](#image-size) section to add this, and the [Demo](demo/components/temp/ProseImg.vue) for an example.
|
|
176
176
|
|
|
177
177
|
### Build
|
|
178
178
|
|
|
@@ -219,10 +219,10 @@ The output path can be customised using a template string:
|
|
|
219
219
|
assets/content/[name]-[hash].[ext]
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
The first part of the path
|
|
222
|
+
The first part of the path is where you want content assets to be served from:
|
|
223
223
|
|
|
224
224
|
```
|
|
225
|
-
assets/
|
|
225
|
+
assets/content/
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
The optional second part of the path indicates the relative location of each image:
|
|
@@ -323,30 +323,51 @@ If you want to see what the module does as it runs, set `debug` to true:
|
|
|
323
323
|
|
|
324
324
|
Should you wish to develop the project, the scripts are:
|
|
325
325
|
|
|
326
|
+
Develop the module itself:
|
|
327
|
+
|
|
326
328
|
```bash
|
|
327
329
|
# install dependencies
|
|
328
330
|
npm install
|
|
329
331
|
|
|
330
|
-
#
|
|
331
|
-
npm run dev:prepare
|
|
332
|
-
|
|
333
|
-
# develop with the demo
|
|
332
|
+
# develop (runs using the demo)
|
|
334
333
|
npm run dev
|
|
335
334
|
|
|
336
|
-
# build the demo
|
|
337
|
-
npm run dev:build
|
|
338
|
-
|
|
339
335
|
# run eslint
|
|
340
336
|
npm run lint
|
|
341
337
|
|
|
342
338
|
# run vitest
|
|
343
339
|
npm run test
|
|
344
340
|
npm run test:watch
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Build and check the demo:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
# generate demo type stubs
|
|
347
|
+
npm run demo:prepare
|
|
345
348
|
|
|
349
|
+
# generate the demo output
|
|
350
|
+
npm run demo:generate
|
|
351
|
+
|
|
352
|
+
# serve the demo output
|
|
353
|
+
npm run demo:serve
|
|
354
|
+
|
|
355
|
+
# build the demo
|
|
356
|
+
npm run demo:build
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Make a new release:
|
|
360
|
+
|
|
361
|
+
```bash
|
|
346
362
|
# release new version
|
|
347
363
|
npm run release
|
|
364
|
+
|
|
365
|
+
# dry run the release
|
|
366
|
+
npm run release:dry
|
|
348
367
|
```
|
|
349
368
|
|
|
369
|
+
Make sure to edit changelog and update `package.json` version first!
|
|
370
|
+
|
|
350
371
|
<!-- Badges -->
|
|
351
372
|
[npm-version-src]: https://img.shields.io/npm/v/nuxt-content-assets/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
352
373
|
[npm-version-href]: https://npmjs.com/package/nuxt-content-assets
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -87,7 +87,7 @@ const module = defineNuxtModule({
|
|
|
87
87
|
debug: false
|
|
88
88
|
},
|
|
89
89
|
setup(options, nuxt) {
|
|
90
|
-
var _a;
|
|
90
|
+
var _a, _b;
|
|
91
91
|
const pluginPath = resolve("./runtime/plugin");
|
|
92
92
|
const buildPath = nuxt.options.buildDir;
|
|
93
93
|
const cachePath = Path.resolve(buildPath, "content-assets");
|
|
@@ -146,8 +146,9 @@ const module = defineNuxtModule({
|
|
|
146
146
|
const publicFolder = Path.join(cachePath, assetsDir);
|
|
147
147
|
const sourceFolders = Object.values(sources);
|
|
148
148
|
const assets = {};
|
|
149
|
+
(_a = nuxt.options).content || (_a.content = {});
|
|
149
150
|
if (nuxt.options.content) {
|
|
150
|
-
(
|
|
151
|
+
(_b = nuxt.options.content).ignores || (_b.ignores = []);
|
|
151
152
|
}
|
|
152
153
|
sourceFolders.forEach((folder) => {
|
|
153
154
|
const pattern = `${folder}/**/*.{${extensions.join(",")}}`;
|
package/dist/runtime/plugin.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { NitroAppPlugin } from 'nitropack';
|
|
2
|
+
declare const plugin: NitroAppPlugin;
|
|
3
|
+
export default plugin;
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -14,8 +14,8 @@ function getAsset(absDoc, relAsset) {
|
|
|
14
14
|
const absAsset = Path.join(Path.dirname(absDoc), relAsset);
|
|
15
15
|
return assets[absAsset] || {};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const plugin = async (nitro) => {
|
|
18
|
+
nitro.hooks.hook("content:file:afterParse", async (file) => {
|
|
19
19
|
if (file._id.endsWith(".md")) {
|
|
20
20
|
const absDoc = getDocPath(file._id);
|
|
21
21
|
const filter = (value, key) => !(String(key).startsWith("_") || key === "body");
|
|
@@ -52,4 +52,5 @@ export default defineNitroPlugin(async (nitroApp) => {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
}
|
|
55
|
+
};
|
|
56
|
+
export default plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-content-assets",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Enable locally-located assets in Nuxt Content",
|
|
5
5
|
"repository": "davestewart/nuxt-content-assets",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,15 +19,16 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "nuxi dev demo",
|
|
22
|
-
"dev:build": "nuxi build demo",
|
|
23
|
-
"dev:prepare": "nuxt-module-build --stub && nuxi prepare demo",
|
|
24
22
|
"build": "nuxt-module-build",
|
|
25
|
-
"release": "npm run lint && npm run test && npm run build && npm publish && git push --follow-tags",
|
|
26
|
-
"release:dry": "npm run lint && npm run test && npm run build && npm publish --dry-run",
|
|
27
|
-
"release:old": "npm run lint && npm run test && npm run build && changelogen --release && npm publish && git push --follow-tags",
|
|
28
23
|
"lint": "eslint .",
|
|
29
24
|
"test": "vitest run",
|
|
30
|
-
"test:watch": "vitest watch"
|
|
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"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@nuxt/kit": "^3.3.2",
|