nuxt-content-assets 1.1.0 → 1.2.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 +25 -19
- package/dist/module.d.ts +19 -1
- package/dist/module.json +4 -3
- package/dist/module.mjs +350 -189
- package/dist/runtime/assets/public.d.ts +41 -0
- package/dist/runtime/assets/public.mjs +111 -0
- package/dist/runtime/{services/sources.d.ts → assets/source.d.ts} +4 -4
- package/dist/runtime/{services/sources.mjs → assets/source.mjs} +4 -14
- package/dist/runtime/content/parsed.d.ts +5 -0
- package/dist/runtime/content/parsed.mjs +32 -0
- package/dist/runtime/content/plugin.mjs +65 -0
- package/dist/runtime/sockets/factory.d.ts +5 -1
- package/dist/runtime/sockets/factory.mjs +3 -10
- package/dist/runtime/sockets/plugin.d.ts +3 -0
- package/dist/runtime/sockets/plugin.mjs +31 -8
- package/dist/runtime/sockets/setup.d.ts +1 -1
- package/dist/runtime/sockets/setup.mjs +15 -2
- package/dist/runtime/utils/config.d.ts +11 -0
- package/dist/runtime/utils/config.mjs +12 -0
- package/dist/runtime/utils/content.d.ts +16 -0
- package/dist/runtime/utils/content.mjs +43 -0
- package/dist/runtime/utils/index.d.ts +2 -0
- package/dist/runtime/utils/index.mjs +2 -0
- package/dist/runtime/utils/object.d.ts +7 -3
- package/dist/runtime/utils/object.mjs +5 -2
- package/dist/runtime/utils/path.mjs +1 -1
- package/dist/types.d.ts +1 -5
- package/package.json +2 -4
- package/dist/runtime/config.d.ts +0 -2
- package/dist/runtime/config.mjs +0 -2
- package/dist/runtime/options.d.ts +0 -10
- package/dist/runtime/options.mjs +0 -18
- package/dist/runtime/plugin.mjs +0 -118
- package/dist/runtime/services/assets.d.ts +0 -32
- package/dist/runtime/services/assets.mjs +0 -42
- package/dist/runtime/services/index.d.ts +0 -3
- package/dist/runtime/services/index.mjs +0 -3
- package/dist/runtime/services/paths.d.ts +0 -8
- package/dist/runtime/services/paths.mjs +0 -26
- package/dist/runtime/sockets/composable.d.ts +0 -2
- package/dist/runtime/sockets/composable.mjs +0 -12
- /package/dist/runtime/{plugin.d.ts → content/plugin.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -65,17 +65,22 @@ Developer experience:
|
|
|
65
65
|
|
|
66
66
|
## Demo
|
|
67
67
|
|
|
68
|
-
To
|
|
68
|
+
To clone and run the demo locally:
|
|
69
69
|
|
|
70
|
-
```
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/davestewart/nuxt-content-assets.git
|
|
72
|
+
cd nuxt-content-assets
|
|
73
|
+
npm install
|
|
71
74
|
npm run dev
|
|
72
75
|
```
|
|
73
76
|
|
|
74
|
-
|
|
77
|
+
Then open the demo in your browser at <a href="http://localhost:3000" target="_blank">localhost:3000</a>.
|
|
78
|
+
|
|
79
|
+
To run the demo online, visit:
|
|
75
80
|
|
|
76
81
|
- https://stackblitz.com/github/davestewart/nuxt-content-assets?file=demo%2Fapp.vue
|
|
77
82
|
|
|
78
|
-
|
|
83
|
+
To browse the demo folder:
|
|
79
84
|
|
|
80
85
|
- https://github.com/davestewart/nuxt-content-assets/tree/main/demo
|
|
81
86
|
|
|
@@ -162,11 +167,11 @@ The module is [preconfigured](#image-size) to pass image size hints (by default
|
|
|
162
167
|
<img src="/image.jpg" width="640" height="480">
|
|
163
168
|
```
|
|
164
169
|
|
|
165
|
-
|
|
170
|
+
Keeping this on prevents content jumps as your page loads.
|
|
166
171
|
|
|
167
172
|
#### Prose components
|
|
168
173
|
|
|
169
|
-
If you use [ProseImg](https://content.nuxtjs.org/api/components/prose) components, you can
|
|
174
|
+
If you use [ProseImg](https://content.nuxtjs.org/api/components/prose) components, you can [hook into](demo/components/temp/ProseImg.vue) image size hints via the `$attrs` property:
|
|
170
175
|
|
|
171
176
|
```vue
|
|
172
177
|
<template>
|
|
@@ -184,13 +189,13 @@ export default {
|
|
|
184
189
|
|
|
185
190
|
#### Frontmatter
|
|
186
191
|
|
|
187
|
-
If you pass [frontmatter](demo/content/advanced/gallery.md) to [custom components](demo/components/content/ContentImage.vue)
|
|
192
|
+
If you pass [frontmatter](demo/content/advanced/gallery.md) to [custom components](demo/components/content/ContentImage.vue) set `imageSize` to `'src'` to encode values in `src`:
|
|
188
193
|
|
|
189
194
|
```
|
|
190
195
|
:image-content{:src="image"}
|
|
191
196
|
```
|
|
192
197
|
|
|
193
|
-
The component will receive the
|
|
198
|
+
The component will receive the size information as a query string which you can extract and apply:
|
|
194
199
|
|
|
195
200
|
```html
|
|
196
201
|
<img class="image-content" src="/image.jpg?width=640&height=480">
|
|
@@ -200,7 +205,7 @@ See demo component [here](demo/components/content/ContentImage.vue).
|
|
|
200
205
|
|
|
201
206
|
## Configuration
|
|
202
207
|
|
|
203
|
-
The module
|
|
208
|
+
The module has the following options:
|
|
204
209
|
|
|
205
210
|
```ts
|
|
206
211
|
// nuxt.config.ts
|
|
@@ -230,13 +235,14 @@ You can add one or more image size hints to the generated images:
|
|
|
230
235
|
|
|
231
236
|
Pick from the following switches:
|
|
232
237
|
|
|
233
|
-
| Switch
|
|
234
|
-
|
|
|
235
|
-
| `style` | Adds `style="aspect-ratio:..."` to any `<img>` tag |
|
|
236
|
-
| `attrs` | Adds `width` and `height` attributes to any `<img>` tag |
|
|
237
|
-
| `src` | Adds `?width=...&height=...` to `src` attribute (frontmatter only) |
|
|
238
|
+
| Switch | What it does |
|
|
239
|
+
| --------- | ------------------------------------------------------------ |
|
|
240
|
+
| `'style'` | Adds `style="aspect-ratio:..."` to any `<img>` tag |
|
|
241
|
+
| `'attrs'` | Adds `width` and `height` attributes to any `<img>` tag |
|
|
242
|
+
| `'src'` | Adds `?width=...&height=...` to `src` attribute (frontmatter only) |
|
|
243
|
+
| `false` | Disable image size hints |
|
|
238
244
|
|
|
239
|
-
Note: if you add *only* `attrs
|
|
245
|
+
Note: if you add *only* `attrs`, include the following CSS in your app:
|
|
240
246
|
|
|
241
247
|
```css
|
|
242
248
|
img {
|
|
@@ -245,10 +251,10 @@ img {
|
|
|
245
251
|
}
|
|
246
252
|
```
|
|
247
253
|
|
|
248
|
-
To disable, pass `false`.
|
|
249
|
-
|
|
250
254
|
### Content extensions
|
|
251
255
|
|
|
256
|
+
> Generally, you shouldn't need to touch this setting
|
|
257
|
+
|
|
252
258
|
This setting tells Nuxt Content to ignore anything that is **not** one of these file extensions:
|
|
253
259
|
|
|
254
260
|
```
|
|
@@ -257,8 +263,6 @@ md csv ya?ml json
|
|
|
257
263
|
|
|
258
264
|
This way, you can use any **other** file type as an asset, without needing to explicitly configure extensions.
|
|
259
265
|
|
|
260
|
-
Generally, you shouldn't need to touch this setting.
|
|
261
|
-
|
|
262
266
|
### Debug
|
|
263
267
|
|
|
264
268
|
If you want to see what the module does as it runs, set `debug` to true:
|
|
@@ -279,6 +283,8 @@ If they do, then the attribute or property is rewritten with the absolute path.
|
|
|
279
283
|
|
|
280
284
|
Finally, Nitro serves the site, and any requests made to the transformed asset paths should be picked up and the *copied* asset served by the browser.
|
|
281
285
|
|
|
286
|
+
In development, file watching propagates asset changes to the public folder, updates related cached content, and notifies the browser via web sockets to refresh any loaded images.
|
|
287
|
+
|
|
282
288
|
## Development
|
|
283
289
|
|
|
284
290
|
Should you wish to develop the project, the scripts are:
|
package/dist/module.d.ts
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
3
|
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Image size hints
|
|
6
|
+
*
|
|
7
|
+
* @example 'attrs style url'
|
|
8
|
+
* @default 'style'
|
|
9
|
+
*/
|
|
4
10
|
imageSize?: string | string[] | false;
|
|
5
|
-
|
|
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
|
+
*/
|
|
6
24
|
debug?: boolean;
|
|
7
25
|
}
|
|
8
26
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
package/dist/module.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"moduleName": "nuxt-content-assets",
|
|
3
|
+
"moduleKey": "contentAssets",
|
|
4
4
|
"compatibility": {
|
|
5
5
|
"nuxt": "^3.0.0"
|
|
6
6
|
},
|
|
7
|
-
"
|
|
7
|
+
"name": "nuxt-content-assets",
|
|
8
|
+
"version": "1.2.0"
|
|
8
9
|
}
|