sveltekit-data-plugin 1.2.1 → 1.2.2
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 +2 -0
- package/dist/plugin.js +9 -5
- package/dist/plugin.mjs +9 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Quite a mouthful. This tries to be a plugin for importing data easily, including
|
|
|
4
4
|
|
|
5
5
|
This is designed to use with `@sveltejs/enhanced-img` and will turn your image assets into valid `Picture` objects to pass directly to your `<enhanced:img/>` components, from markdown files in a folder, generated by something like [Netlify CMS](https://decapcms.org/docs/intro/)
|
|
6
6
|
|
|
7
|
+
It will also convert some URLs into oembed data
|
|
8
|
+
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
11
|
```
|
package/dist/plugin.js
CHANGED
|
@@ -110,15 +110,19 @@
|
|
|
110
110
|
buildStart() {
|
|
111
111
|
opts.plugin_context = this;
|
|
112
112
|
},
|
|
113
|
-
async
|
|
113
|
+
async transformFile(src) {
|
|
114
114
|
var _a;
|
|
115
|
+
const base2 = path.resolve(((_a = opts.vite_config) == null ? void 0 : _a.root) ?? "", opts.base);
|
|
116
|
+
const d = fm(src);
|
|
117
|
+
const attributes = await convert(opts, d.attributes, base2);
|
|
118
|
+
return { attributes, body: d.body };
|
|
119
|
+
},
|
|
120
|
+
async transform(src, id) {
|
|
115
121
|
if (/\.(md)$/.test(id)) {
|
|
116
|
-
const
|
|
117
|
-
const d = fm(src);
|
|
118
|
-
const attributes = await convert(opts, d.attributes, base2);
|
|
122
|
+
const { attributes, body } = await this.transformFile(src);
|
|
119
123
|
return `
|
|
120
124
|
${Object.entries(attributes).map(([key, value]) => `export const ${key} = ${JSON.stringify(value)};`).join("\n")}
|
|
121
|
-
export const body = ${JSON.stringify(
|
|
125
|
+
export const body = ${JSON.stringify(body)};`;
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
};
|
package/dist/plugin.mjs
CHANGED
|
@@ -109,15 +109,19 @@ function importDataPlugin(imagetools_plugin, { base = "./src/data" } = {}) {
|
|
|
109
109
|
buildStart() {
|
|
110
110
|
opts.plugin_context = this;
|
|
111
111
|
},
|
|
112
|
-
async
|
|
112
|
+
async transformFile(src) {
|
|
113
113
|
var _a;
|
|
114
|
+
const base2 = path.resolve(((_a = opts.vite_config) == null ? void 0 : _a.root) ?? "", opts.base);
|
|
115
|
+
const d = fm(src);
|
|
116
|
+
const attributes = await convert(opts, d.attributes, base2);
|
|
117
|
+
return { attributes, body: d.body };
|
|
118
|
+
},
|
|
119
|
+
async transform(src, id) {
|
|
114
120
|
if (/\.(md)$/.test(id)) {
|
|
115
|
-
const
|
|
116
|
-
const d = fm(src);
|
|
117
|
-
const attributes = await convert(opts, d.attributes, base2);
|
|
121
|
+
const { attributes, body } = await this.transformFile(src);
|
|
118
122
|
return `
|
|
119
123
|
${Object.entries(attributes).map(([key, value]) => `export const ${key} = ${JSON.stringify(value)};`).join("\n")}
|
|
120
|
-
export const body = ${JSON.stringify(
|
|
124
|
+
export const body = ${JSON.stringify(body)};`;
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
127
|
};
|