sveltekit-data-plugin 1.2.0 → 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 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
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory(require("front-matter"), require("path"), require("fs/promises"), require("node:fe")) : typeof define === "function" && define.amd ? define(["front-matter", "path", "fs/promises", "node:fe"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global["Sveltekit Data Plugin"] = factory(global.fm, global.path, global.fs, global.fetch));
3
- })(this, function(fm, path, fs, fetch) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory(require("front-matter"), require("path"), require("fs/promises")) : typeof define === "function" && define.amd ? define(["front-matter", "path", "fs/promises"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global["Sveltekit Data Plugin"] = factory(global.fm, global.path, global.fs));
3
+ })(this, function(fm, path, fs) {
4
4
  "use strict";
5
5
  const REGEX = {
6
6
  IMAGE: /^\S*(jpg|png|webp|avif|jpeg)$/,
@@ -110,15 +110,19 @@
110
110
  buildStart() {
111
111
  opts.plugin_context = this;
112
112
  },
113
- async transform(src, id) {
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 base2 = path.resolve(((_a = opts.vite_config) == null ? void 0 : _a.root) ?? "", opts.base);
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(d.body)};`;
125
+ export const body = ${JSON.stringify(body)};`;
122
126
  }
123
127
  }
124
128
  };
package/dist/plugin.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import fm from "front-matter";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
- import fetch from "node:fe";
5
4
  const REGEX = {
6
5
  IMAGE: /^\S*(jpg|png|webp|avif|jpeg)$/,
7
6
  YOUTUBE: /^(https?\:\/\/)?((www\.)?youtube\.com|youtu\.be)\/.+$/
@@ -110,15 +109,19 @@ function importDataPlugin(imagetools_plugin, { base = "./src/data" } = {}) {
110
109
  buildStart() {
111
110
  opts.plugin_context = this;
112
111
  },
113
- async transform(src, id) {
112
+ async transformFile(src) {
114
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) {
115
120
  if (/\.(md)$/.test(id)) {
116
- const base2 = path.resolve(((_a = opts.vite_config) == null ? void 0 : _a.root) ?? "", opts.base);
117
- const d = fm(src);
118
- const attributes = await convert(opts, d.attributes, base2);
121
+ const { attributes, body } = await this.transformFile(src);
119
122
  return `
120
123
  ${Object.entries(attributes).map(([key, value]) => `export const ${key} = ${JSON.stringify(value)};`).join("\n")}
121
- export const body = ${JSON.stringify(d.body)};`;
124
+ export const body = ${JSON.stringify(body)};`;
122
125
  }
123
126
  }
124
127
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltekit-data-plugin",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "author": {
5
5
  "name": "Jonny Thaw",
6
6
  "url": "https://jthaw.me"