@storyblok/astro 2.0.2 → 2.0.3
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/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ISbConfig, ISbRichtext, SbRichTextOptions } from "./types";
|
|
|
4
4
|
export { storyblokEditable, loadStoryblokBridge, RichTextResolver, RichTextSchema, } from "@storyblok/js";
|
|
5
5
|
export declare function useStoryblokApi(): StoryblokClient;
|
|
6
6
|
export declare function renderRichText(data: ISbRichtext, options?: SbRichTextOptions): string;
|
|
7
|
-
export
|
|
7
|
+
export declare type IntegrationOptions = {
|
|
8
8
|
/**
|
|
9
9
|
* The access token from your space.
|
|
10
10
|
*/
|
|
@@ -12,7 +12,7 @@ export interface IntegrationOptions {
|
|
|
12
12
|
/**
|
|
13
13
|
* If you want to use your own method to fetch data from Storyblok, you can disable this behavior by setting `useCustomApi` to `true`, resulting in an optimized final bundle.
|
|
14
14
|
*/
|
|
15
|
-
useCustomApi?:
|
|
15
|
+
useCustomApi?: boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Set custom API options here (cache, region, and more). All options are documented [here](https://github.com/storyblok/storyblok-js-client#class-storyblok).
|
|
18
18
|
*/
|
|
@@ -34,6 +34,6 @@ export interface IntegrationOptions {
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
components?: object;
|
|
37
|
-
}
|
|
38
|
-
export default function storyblokIntegration(options
|
|
37
|
+
};
|
|
38
|
+
export default function storyblokIntegration(options: IntegrationOptions): AstroIntegration;
|
|
39
39
|
export * from "./types";
|
|
@@ -2647,7 +2647,7 @@ export declare interface WatchOptions {
|
|
|
2647
2647
|
|
|
2648
2648
|
/**
|
|
2649
2649
|
* Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
|
|
2650
|
-
* and `fsevents` is available this
|
|
2650
|
+
* and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
|
|
2651
2651
|
* OS X, `usePolling: true` becomes the default.
|
|
2652
2652
|
*/
|
|
2653
2653
|
useFsEvents?: boolean
|
package/dist/storyblok-astro.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(a,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(a=typeof globalThis<"u"?globalThis:a||self,u(a.storyblokAstro={}))})(this,function(a){"use strict";function u(t,e,r){const o="virtual:storyblok-init",n="\0"+o;return{name:"vite-plugin-storyblok-init",async resolveId(s){if(s===o)return n},async load(s){if(s===n)return`
|
|
2
2
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
3
3
|
const { storyblokApi } = storyblokInit({
|
|
4
4
|
accessToken: "${t}",
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
apiOptions: ${JSON.stringify(r)},
|
|
7
7
|
});
|
|
8
8
|
export const storyblokApiInstance = storyblokApi;
|
|
9
|
-
`}}}const
|
|
9
|
+
`}}}const w=/[\p{Lu}]/u,S=/[\p{Ll}]/u,f=/^[\p{Lu}](?![\p{Lu}])/gu,h=/([\p{Alpha}\p{N}_]|$)/u,g=/[_.\- ]+/,C=new RegExp("^"+g.source),p=new RegExp(g.source+h.source,"gu"),b=new RegExp("\\d+"+h.source,"gu"),R=(t,e,r,o)=>{let n=!1,s=!1,c=!1,d=!1;for(let i=0;i<t.length;i++){const l=t[i];d=i>2?t[i-3]==="-":!0,n&&w.test(l)?(t=t.slice(0,i)+"-"+t.slice(i),n=!1,c=s,s=!0,i++):s&&c&&S.test(l)&&(!d||o)?(t=t.slice(0,i-1)+"-"+t.slice(i-1),c=s,s=!1,n=!0):(n=e(l)===l&&r(l)!==l,c=s,s=r(l)===l&&e(l)!==l)}return t},_=(t,e)=>(f.lastIndex=0,t.replace(f,r=>e(r))),$=(t,e)=>(p.lastIndex=0,b.lastIndex=0,t.replace(p,(r,o)=>e(o)).replace(b,r=>e(r)));function y(t,e){if(!(typeof t=="string"||Array.isArray(t)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(t)?t=t.map(s=>s.trim()).filter(s=>s.length).join("-"):t=t.trim(),t.length===0)return"";const r=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),o=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return t.length===1?g.test(t)?"":e.pascalCase?o(t):r(t):(t!==r(t)&&(t=R(t,r,o,e.preserveConsecutiveUppercase)),t=t.replace(C,""),t=e.preserveConsecutiveUppercase?_(t,r):r(t),e.pascalCase&&(t=o(t.charAt(0))+t.slice(1)),$(t,o))}function O(t){const e="virtual:storyblok-components",r="\0"+e;return{name:"vite-plugin-storyblok-components",async resolveId(o){if(o===e)return r},async load(o){if(o===r){const n=[];for await(const[s,c]of Object.entries(t)){const{id:d}=await this.resolve("/src/"+c+".astro");n.push(`import ${y(s)} from "${d}"`)}return`${n.join(";")};export default {${Object.keys(t).map(s=>y(s)).join(",")}}`}}}}var P=Object.defineProperty,m=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,k=(t,e,r)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,N=(t,e)=>{for(var r in e||(e={}))x.call(e,r)&&k(t,r,e[r]);if(m)for(var r of m(e))j.call(e,r)&&k(t,r,e[r]);return t};let v=!1;const T=[],L=t=>new Promise((e,r)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=n=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}v?n():T.push(n)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=t,o.id="storyblok-javascript-bridge",o.onerror=n=>r(n),o.onload=n=>{T.forEach(s=>s()),v=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(o)});var M=Object.defineProperty,U=(t,e,r)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,I=(t,e,r)=>(U(t,typeof e!="symbol"?e+"":e,r),r);const B=function(t,e){const r={};for(const o in t){const n=t[o];e.indexOf(o)>-1&&n!==null&&(r[o]=n)}return r},D=t=>t==="email",z=()=>({singleTag:"hr"}),F=()=>({tag:"blockquote"}),V=()=>({tag:"ul"}),q=t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),J=()=>({singleTag:"br"}),G=t=>({tag:`h${t.attrs.level}`}),K=t=>({singleTag:[{tag:"img",attrs:B(t.attrs,["src","alt","title"])}]}),H=()=>({tag:"li"}),W=()=>({tag:"ol"}),Y=()=>({tag:"p"}),Q=()=>({tag:"b"}),X=()=>({tag:"strike"}),Z=()=>({tag:"u"}),ee=()=>({tag:"strong"}),te=()=>({tag:"code"}),re=()=>({tag:"i"}),oe=t=>{const e=N({},t.attrs),{linktype:r="url"}=t.attrs;return D(r)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},se=t=>({tag:[{tag:"span",attrs:t.attrs}]}),A={nodes:{horizontal_rule:z,blockquote:F,bullet_list:V,code_block:q,hard_break:J,heading:G,image:K,list_item:H,ordered_list:W,paragraph:Y},marks:{bold:Q,strike:X,underline:Z,strong:ee,code:te,italic:re,link:oe,styled:se}},ne=function(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,o=RegExp(r.source);return t&&o.test(t)?t.replace(r,n=>e[n]):t};class E{constructor(e){I(this,"marks"),I(this,"nodes"),e||(e=A),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,r){this.nodes[e]=r}addMark(e,r){this.marks[e]=r}render(e){if(e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(o=>{r+=this.renderNode(o)}),r}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){const r=[];e.marks&&e.marks.forEach(n=>{const s=this.getMatchingMark(n);s&&r.push(this.renderOpeningTag(s.tag))});const o=this.getMatchingNode(e);return o&&o.tag&&r.push(this.renderOpeningTag(o.tag)),e.content?e.content.forEach(n=>{r.push(this.renderNode(n))}):e.text?r.push(ne(e.text)):o&&o.singleTag?r.push(this.renderTag(o.singleTag," /")):o&&o.html&&r.push(o.html),o&&o.tag&&r.push(this.renderClosingTag(o.tag)),e.marks&&e.marks.slice(0).reverse().forEach(n=>{const s=this.getMatchingMark(n);s&&r.push(this.renderClosingTag(s.tag))}),r.join("")}renderTag(e,r){return e.constructor===String?`<${e}${r}>`:e.map(o=>{if(o.constructor===String)return`<${o}${r}>`;{let n=`<${o.tag}`;if(o.attrs)for(const s in o.attrs){const c=o.attrs[s];c!==null&&(n+=` ${s}="${c}"`)}return`${n}${r}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(r=>r.constructor===String?`</${r}>`:`</${r.tag}>`).join("")}getMatchingNode(e){const r=this.nodes[e.type];if(typeof r=="function")return r(e)}getMatchingMark(e){const r=this.marks[e.type];if(typeof r=="function")return r(e)}}var ae=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let ie;const le="https://app.storyblok.com/f/storyblok-v2-latest.js",ce=(t,e)=>{t.addNode("blok",r=>{let o="";return r.attrs.body.forEach(n=>{o+=e(n.component,n)}),{html:o}})},ue=(t,e,r)=>{let o=r||ie;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return t===""?"":t?(e&&(o=new E(e.schema),e.resolver&&ce(o,e.resolver)),o.render(t)):(console.warn(`${t} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
10
10
|
|
|
11
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},
|
|
11
|
+
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},de=()=>L(le);function ge(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function fe(t,e){const r=globalThis.storyblokApiInstance.richTextResolver;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return ue(t,e,r)}function he(t){const e={useCustomApi:!1,bridge:!0,...t};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:r,updateConfig:o})=>{o({vite:{plugins:[u(e.accessToken,e.useCustomApi,e.apiOptions),O(e.components)]}}),r("page-ssr",`
|
|
12
12
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
13
13
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
14
|
-
`),
|
|
14
|
+
`),e.bridge&&r("page",`
|
|
15
15
|
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
16
16
|
loadStoryblokBridge().then(() => {
|
|
17
17
|
const { StoryblokBridge, location } = window;
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
`)}}}}
|
|
26
|
+
`)}}}}a.RichTextResolver=E,a.RichTextSchema=A,a.default=he,a.loadStoryblokBridge=de,a.renderRichText=fe,a.storyblokEditable=ae,a.useStoryblokApi=ge,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/storyblok-astro.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
function
|
|
2
|
-
const o = "virtual:storyblok-init",
|
|
1
|
+
function I(t, e, r) {
|
|
2
|
+
const o = "virtual:storyblok-init", n = "\0" + o;
|
|
3
3
|
return {
|
|
4
4
|
name: "vite-plugin-storyblok-init",
|
|
5
|
-
async resolveId(
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
5
|
+
async resolveId(s) {
|
|
6
|
+
if (s === o)
|
|
7
|
+
return n;
|
|
8
8
|
},
|
|
9
|
-
async load(
|
|
10
|
-
if (
|
|
9
|
+
async load(s) {
|
|
10
|
+
if (s === n)
|
|
11
11
|
return `
|
|
12
12
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
13
13
|
const { storyblokApi } = storyblokInit({
|
|
@@ -20,27 +20,27 @@ function k(t, e, r) {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
let
|
|
23
|
+
const T = /[\p{Lu}]/u, E = /[\p{Ll}]/u, d = /^[\p{Lu}](?![\p{Lu}])/gu, v = /([\p{Alpha}\p{N}_]|$)/u, u = /[_.\- ]+/, A = new RegExp("^" + u.source), g = new RegExp(u.source + v.source, "gu"), h = new RegExp("\\d+" + v.source, "gu"), w = (t, e, r, o) => {
|
|
24
|
+
let n = !1, s = !1, i = !1, c = !1;
|
|
25
25
|
for (let a = 0; a < t.length; a++) {
|
|
26
26
|
const l = t[a];
|
|
27
|
-
|
|
27
|
+
c = a > 2 ? t[a - 3] === "-" : !0, n && T.test(l) ? (t = t.slice(0, a) + "-" + t.slice(a), n = !1, i = s, s = !0, a++) : s && i && E.test(l) && (!c || o) ? (t = t.slice(0, a - 1) + "-" + t.slice(a - 1), i = s, s = !1, n = !0) : (n = e(l) === l && r(l) !== l, i = s, s = r(l) === l && e(l) !== l);
|
|
28
28
|
}
|
|
29
29
|
return t;
|
|
30
|
-
},
|
|
31
|
-
function
|
|
30
|
+
}, C = (t, e) => (d.lastIndex = 0, t.replace(d, (r) => e(r))), S = (t, e) => (g.lastIndex = 0, h.lastIndex = 0, t.replace(g, (r, o) => e(o)).replace(h, (r) => e(r)));
|
|
31
|
+
function p(t, e) {
|
|
32
32
|
if (!(typeof t == "string" || Array.isArray(t)))
|
|
33
33
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
34
34
|
if (e = {
|
|
35
35
|
pascalCase: !1,
|
|
36
36
|
preserveConsecutiveUppercase: !1,
|
|
37
37
|
...e
|
|
38
|
-
}, Array.isArray(t) ? t = t.map((
|
|
38
|
+
}, Array.isArray(t) ? t = t.map((s) => s.trim()).filter((s) => s.length).join("-") : t = t.trim(), t.length === 0)
|
|
39
39
|
return "";
|
|
40
|
-
const r = e.locale === !1 ? (
|
|
41
|
-
return t.length === 1 ?
|
|
40
|
+
const r = e.locale === !1 ? (s) => s.toLowerCase() : (s) => s.toLocaleLowerCase(e.locale), o = e.locale === !1 ? (s) => s.toUpperCase() : (s) => s.toLocaleUpperCase(e.locale);
|
|
41
|
+
return t.length === 1 ? u.test(t) ? "" : e.pascalCase ? o(t) : r(t) : (t !== r(t) && (t = w(t, r, o, e.preserveConsecutiveUppercase)), t = t.replace(A, ""), t = e.preserveConsecutiveUppercase ? C(t, r) : r(t), e.pascalCase && (t = o(t.charAt(0)) + t.slice(1)), S(t, o));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function R(t) {
|
|
44
44
|
const e = "virtual:storyblok-components", r = "\0" + e;
|
|
45
45
|
return {
|
|
46
46
|
name: "vite-plugin-storyblok-components",
|
|
@@ -50,54 +50,54 @@ function S(t) {
|
|
|
50
50
|
},
|
|
51
51
|
async load(o) {
|
|
52
52
|
if (o === r) {
|
|
53
|
-
const
|
|
54
|
-
for await (const [
|
|
55
|
-
const { id:
|
|
56
|
-
|
|
53
|
+
const n = [];
|
|
54
|
+
for await (const [s, i] of Object.entries(t)) {
|
|
55
|
+
const { id: c } = await this.resolve("/src/" + i + ".astro");
|
|
56
|
+
n.push(`import ${p(s)} from "${c}"`);
|
|
57
57
|
}
|
|
58
|
-
return `${
|
|
58
|
+
return `${n.join(";")};export default {${Object.keys(t).map((s) => p(s)).join(",")}}`;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
var
|
|
63
|
+
var _ = Object.defineProperty, f = Object.getOwnPropertySymbols, x = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable, b = (t, e, r) => e in t ? _(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, O = (t, e) => {
|
|
64
64
|
for (var r in e || (e = {}))
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
for (var r of
|
|
68
|
-
|
|
65
|
+
x.call(e, r) && b(t, r, e[r]);
|
|
66
|
+
if (f)
|
|
67
|
+
for (var r of f(e))
|
|
68
|
+
$.call(e, r) && b(t, r, e[r]);
|
|
69
69
|
return t;
|
|
70
70
|
};
|
|
71
|
-
let
|
|
72
|
-
const
|
|
73
|
-
if (typeof window > "u" || (window.storyblokRegisterEvent = (
|
|
71
|
+
let y = !1;
|
|
72
|
+
const m = [], P = (t) => new Promise((e, r) => {
|
|
73
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
|
|
74
74
|
if (window.location === window.parent.location) {
|
|
75
75
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
y ? n() : m.push(n);
|
|
79
79
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
80
80
|
return;
|
|
81
81
|
const o = document.createElement("script");
|
|
82
|
-
o.async = !0, o.src = t, o.id = "storyblok-javascript-bridge", o.onerror = (
|
|
83
|
-
|
|
82
|
+
o.async = !0, o.src = t, o.id = "storyblok-javascript-bridge", o.onerror = (n) => r(n), o.onload = (n) => {
|
|
83
|
+
m.forEach((s) => s()), y = !0, e(n);
|
|
84
84
|
}, document.getElementsByTagName("head")[0].appendChild(o);
|
|
85
85
|
});
|
|
86
|
-
var
|
|
87
|
-
const
|
|
86
|
+
var N = Object.defineProperty, L = (t, e, r) => e in t ? N(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, k = (t, e, r) => (L(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
87
|
+
const j = function(t, e) {
|
|
88
88
|
const r = {};
|
|
89
89
|
for (const o in t) {
|
|
90
|
-
const
|
|
91
|
-
e.indexOf(o) > -1 &&
|
|
90
|
+
const n = t[o];
|
|
91
|
+
e.indexOf(o) > -1 && n !== null && (r[o] = n);
|
|
92
92
|
}
|
|
93
93
|
return r;
|
|
94
|
-
},
|
|
94
|
+
}, M = (t) => t === "email", U = () => ({
|
|
95
95
|
singleTag: "hr"
|
|
96
|
-
}),
|
|
96
|
+
}), D = () => ({
|
|
97
97
|
tag: "blockquote"
|
|
98
|
-
}),
|
|
98
|
+
}), B = () => ({
|
|
99
99
|
tag: "ul"
|
|
100
|
-
}),
|
|
100
|
+
}), z = (t) => ({
|
|
101
101
|
tag: [
|
|
102
102
|
"pre",
|
|
103
103
|
{
|
|
@@ -105,38 +105,38 @@ const N = function(t, e) {
|
|
|
105
105
|
attrs: t.attrs
|
|
106
106
|
}
|
|
107
107
|
]
|
|
108
|
-
}),
|
|
108
|
+
}), F = () => ({
|
|
109
109
|
singleTag: "br"
|
|
110
|
-
}),
|
|
110
|
+
}), V = (t) => ({
|
|
111
111
|
tag: `h${t.attrs.level}`
|
|
112
|
-
}),
|
|
112
|
+
}), q = (t) => ({
|
|
113
113
|
singleTag: [
|
|
114
114
|
{
|
|
115
115
|
tag: "img",
|
|
116
|
-
attrs:
|
|
116
|
+
attrs: j(t.attrs, ["src", "alt", "title"])
|
|
117
117
|
}
|
|
118
118
|
]
|
|
119
|
-
}),
|
|
119
|
+
}), J = () => ({
|
|
120
120
|
tag: "li"
|
|
121
|
-
}),
|
|
121
|
+
}), G = () => ({
|
|
122
122
|
tag: "ol"
|
|
123
|
-
}),
|
|
123
|
+
}), K = () => ({
|
|
124
124
|
tag: "p"
|
|
125
|
-
}),
|
|
125
|
+
}), H = () => ({
|
|
126
126
|
tag: "b"
|
|
127
|
-
}),
|
|
127
|
+
}), W = () => ({
|
|
128
128
|
tag: "strike"
|
|
129
|
-
}),
|
|
129
|
+
}), Y = () => ({
|
|
130
130
|
tag: "u"
|
|
131
|
-
}),
|
|
131
|
+
}), Q = () => ({
|
|
132
132
|
tag: "strong"
|
|
133
|
-
}),
|
|
133
|
+
}), X = () => ({
|
|
134
134
|
tag: "code"
|
|
135
|
-
}),
|
|
135
|
+
}), Z = () => ({
|
|
136
136
|
tag: "i"
|
|
137
|
-
}),
|
|
138
|
-
const e =
|
|
139
|
-
return
|
|
137
|
+
}), ee = (t) => {
|
|
138
|
+
const e = O({}, t.attrs), { linktype: r = "url" } = t.attrs;
|
|
139
|
+
return M(r) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
|
|
140
140
|
tag: [
|
|
141
141
|
{
|
|
142
142
|
tag: "a",
|
|
@@ -144,37 +144,37 @@ const N = function(t, e) {
|
|
|
144
144
|
}
|
|
145
145
|
]
|
|
146
146
|
};
|
|
147
|
-
},
|
|
147
|
+
}, te = (t) => ({
|
|
148
148
|
tag: [
|
|
149
149
|
{
|
|
150
150
|
tag: "span",
|
|
151
151
|
attrs: t.attrs
|
|
152
152
|
}
|
|
153
153
|
]
|
|
154
|
-
}),
|
|
154
|
+
}), re = {
|
|
155
155
|
nodes: {
|
|
156
|
-
horizontal_rule:
|
|
157
|
-
blockquote:
|
|
158
|
-
bullet_list:
|
|
159
|
-
code_block:
|
|
160
|
-
hard_break:
|
|
161
|
-
heading:
|
|
162
|
-
image:
|
|
163
|
-
list_item:
|
|
164
|
-
ordered_list:
|
|
165
|
-
paragraph:
|
|
156
|
+
horizontal_rule: U,
|
|
157
|
+
blockquote: D,
|
|
158
|
+
bullet_list: B,
|
|
159
|
+
code_block: z,
|
|
160
|
+
hard_break: F,
|
|
161
|
+
heading: V,
|
|
162
|
+
image: q,
|
|
163
|
+
list_item: J,
|
|
164
|
+
ordered_list: G,
|
|
165
|
+
paragraph: K
|
|
166
166
|
},
|
|
167
167
|
marks: {
|
|
168
|
-
bold:
|
|
169
|
-
strike:
|
|
170
|
-
underline:
|
|
171
|
-
strong:
|
|
172
|
-
code:
|
|
173
|
-
italic:
|
|
174
|
-
link:
|
|
175
|
-
styled:
|
|
168
|
+
bold: H,
|
|
169
|
+
strike: W,
|
|
170
|
+
underline: Y,
|
|
171
|
+
strong: Q,
|
|
172
|
+
code: X,
|
|
173
|
+
italic: Z,
|
|
174
|
+
link: ee,
|
|
175
|
+
styled: te
|
|
176
176
|
}
|
|
177
|
-
},
|
|
177
|
+
}, oe = function(t) {
|
|
178
178
|
const e = {
|
|
179
179
|
"&": "&",
|
|
180
180
|
"<": "<",
|
|
@@ -182,11 +182,11 @@ const N = function(t, e) {
|
|
|
182
182
|
'"': """,
|
|
183
183
|
"'": "'"
|
|
184
184
|
}, r = /[&<>"']/g, o = RegExp(r.source);
|
|
185
|
-
return t && o.test(t) ? t.replace(r, (
|
|
185
|
+
return t && o.test(t) ? t.replace(r, (n) => e[n]) : t;
|
|
186
186
|
};
|
|
187
|
-
class
|
|
187
|
+
class se {
|
|
188
188
|
constructor(e) {
|
|
189
|
-
|
|
189
|
+
k(this, "marks"), k(this, "nodes"), e || (e = re), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
190
190
|
}
|
|
191
191
|
addNode(e, r) {
|
|
192
192
|
this.nodes[e] = r;
|
|
@@ -205,16 +205,16 @@ class re {
|
|
|
205
205
|
}
|
|
206
206
|
renderNode(e) {
|
|
207
207
|
const r = [];
|
|
208
|
-
e.marks && e.marks.forEach((
|
|
209
|
-
const
|
|
210
|
-
|
|
208
|
+
e.marks && e.marks.forEach((n) => {
|
|
209
|
+
const s = this.getMatchingMark(n);
|
|
210
|
+
s && r.push(this.renderOpeningTag(s.tag));
|
|
211
211
|
});
|
|
212
212
|
const o = this.getMatchingNode(e);
|
|
213
|
-
return o && o.tag && r.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((
|
|
214
|
-
r.push(this.renderNode(
|
|
215
|
-
}) : e.text ? r.push(
|
|
216
|
-
const
|
|
217
|
-
|
|
213
|
+
return o && o.tag && r.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((n) => {
|
|
214
|
+
r.push(this.renderNode(n));
|
|
215
|
+
}) : e.text ? r.push(oe(e.text)) : o && o.singleTag ? r.push(this.renderTag(o.singleTag, " /")) : o && o.html && r.push(o.html), o && o.tag && r.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((n) => {
|
|
216
|
+
const s = this.getMatchingMark(n);
|
|
217
|
+
s && r.push(this.renderClosingTag(s.tag));
|
|
218
218
|
}), r.join("");
|
|
219
219
|
}
|
|
220
220
|
renderTag(e, r) {
|
|
@@ -222,13 +222,13 @@ class re {
|
|
|
222
222
|
if (o.constructor === String)
|
|
223
223
|
return `<${o}${r}>`;
|
|
224
224
|
{
|
|
225
|
-
let
|
|
225
|
+
let n = `<${o.tag}`;
|
|
226
226
|
if (o.attrs)
|
|
227
|
-
for (const
|
|
228
|
-
const
|
|
229
|
-
|
|
227
|
+
for (const s in o.attrs) {
|
|
228
|
+
const i = o.attrs[s];
|
|
229
|
+
i !== null && (n += ` ${s}="${i}"`);
|
|
230
230
|
}
|
|
231
|
-
return `${
|
|
231
|
+
return `${n}${r}>`;
|
|
232
232
|
}
|
|
233
233
|
}).join("");
|
|
234
234
|
}
|
|
@@ -249,7 +249,7 @@ class re {
|
|
|
249
249
|
return r(e);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
var
|
|
252
|
+
var ce = (t) => {
|
|
253
253
|
if (typeof t != "object" || typeof t._editable > "u")
|
|
254
254
|
return {};
|
|
255
255
|
const e = JSON.parse(t._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
@@ -258,30 +258,30 @@ var le = (t) => {
|
|
|
258
258
|
"data-blok-uid": e.id + "-" + e.uid
|
|
259
259
|
};
|
|
260
260
|
};
|
|
261
|
-
let
|
|
262
|
-
const
|
|
261
|
+
let ne;
|
|
262
|
+
const ae = "https://app.storyblok.com/f/storyblok-v2-latest.js", le = (t, e) => {
|
|
263
263
|
t.addNode("blok", (r) => {
|
|
264
264
|
let o = "";
|
|
265
|
-
return r.attrs.body.forEach((
|
|
266
|
-
o += e(
|
|
265
|
+
return r.attrs.body.forEach((n) => {
|
|
266
|
+
o += e(n.component, n);
|
|
267
267
|
}), {
|
|
268
268
|
html: o
|
|
269
269
|
};
|
|
270
270
|
});
|
|
271
|
-
},
|
|
272
|
-
let o = r ||
|
|
271
|
+
}, ie = (t, e, r) => {
|
|
272
|
+
let o = r || ne;
|
|
273
273
|
if (!o) {
|
|
274
274
|
console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
|
-
return t === "" ? "" : t ? (e && (o = new
|
|
277
|
+
return t === "" ? "" : t ? (e && (o = new se(e.schema), e.resolver && le(o, e.resolver)), o.render(t)) : (console.warn(`${t} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
278
278
|
|
|
279
279
|
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
|
|
280
|
-
},
|
|
281
|
-
function
|
|
280
|
+
}, ue = () => P(ae);
|
|
281
|
+
function de() {
|
|
282
282
|
return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function ge(t, e) {
|
|
285
285
|
const r = globalThis.storyblokApiInstance.richTextResolver;
|
|
286
286
|
if (!r) {
|
|
287
287
|
console.error(
|
|
@@ -289,37 +289,36 @@ function ue(t, e) {
|
|
|
289
289
|
);
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
|
-
return
|
|
292
|
+
return ie(t, e, r);
|
|
293
293
|
}
|
|
294
|
-
function
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}) {
|
|
294
|
+
function he(t) {
|
|
295
|
+
const e = {
|
|
296
|
+
useCustomApi: !1,
|
|
297
|
+
bridge: !0,
|
|
298
|
+
...t
|
|
299
|
+
};
|
|
301
300
|
return {
|
|
302
301
|
name: "@storyblok/astro",
|
|
303
302
|
hooks: {
|
|
304
|
-
"astro:config:setup": ({ injectScript:
|
|
305
|
-
|
|
303
|
+
"astro:config:setup": ({ injectScript: r, updateConfig: o }) => {
|
|
304
|
+
o({
|
|
306
305
|
vite: {
|
|
307
306
|
plugins: [
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
307
|
+
I(
|
|
308
|
+
e.accessToken,
|
|
309
|
+
e.useCustomApi,
|
|
310
|
+
e.apiOptions
|
|
312
311
|
),
|
|
313
|
-
|
|
312
|
+
R(e.components)
|
|
314
313
|
]
|
|
315
314
|
}
|
|
316
|
-
}),
|
|
315
|
+
}), r(
|
|
317
316
|
"page-ssr",
|
|
318
317
|
`
|
|
319
318
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
320
319
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
321
320
|
`
|
|
322
|
-
),
|
|
321
|
+
), e.bridge && r(
|
|
323
322
|
"page",
|
|
324
323
|
`
|
|
325
324
|
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
@@ -340,11 +339,11 @@ function de(t = {
|
|
|
340
339
|
};
|
|
341
340
|
}
|
|
342
341
|
export {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
342
|
+
se as RichTextResolver,
|
|
343
|
+
re as RichTextSchema,
|
|
344
|
+
he as default,
|
|
345
|
+
ue as loadStoryblokBridge,
|
|
346
|
+
ge as renderRichText,
|
|
347
|
+
ce as storyblokEditable,
|
|
348
|
+
de as useStoryblokApi
|
|
350
349
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/astro",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Official Astro integration for the Storyblok Headless CMS",
|
|
5
5
|
"main": "./dist/storyblok-astro.js",
|
|
6
6
|
"module": "./dist/storyblok-astro.mjs",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"prepublishOnly": "npm run build && cp ../README.md ./"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@storyblok/js": "^2.0.
|
|
32
|
-
"camelcase": "^7.0.
|
|
31
|
+
"@storyblok/js": "^2.0.6",
|
|
32
|
+
"camelcase": "^7.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@cypress/vite-dev-server": "^5.0.2",
|
|
36
|
-
"@rollup/plugin-dynamic-import-vars": "^2.0.
|
|
37
|
-
"@types/node": "18.11.
|
|
38
|
-
"astro": "1.
|
|
39
|
-
"cypress": "^12.
|
|
36
|
+
"@rollup/plugin-dynamic-import-vars": "^2.0.2",
|
|
37
|
+
"@types/node": "18.11.18",
|
|
38
|
+
"astro": "1.9.2",
|
|
39
|
+
"cypress": "^12.3.0",
|
|
40
40
|
"eslint-plugin-cypress": "^2.12.1",
|
|
41
41
|
"start-server-and-test": "^1.15.2",
|
|
42
42
|
"typescript": "4.9.4",
|
|
43
|
-
"vite": "^4.0.
|
|
43
|
+
"vite": "^4.0.4",
|
|
44
44
|
"vite-plugin-dts": "^1.7.1"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|