@storyblok/astro 2.1.0 → 2.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 +8 -2
- package/StoryblokComponent.astro +18 -12
- package/dist/storyblok-astro.js +4 -4
- package/dist/storyblok-astro.mjs +180 -142
- package/dist/types/index.d.ts +9 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<a href="https://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro" align="center">
|
|
3
|
-
<img src="https://a.storyblok.com/f/88751/1500x500/7974d6bc34/storyblok-astro.png" width="300" height="100" alt="Storyblok + Astro">
|
|
3
|
+
<img src="https://a.storyblok.com/f/88751/1500x500/7974d6bc34/storyblok-astro.png#1" width="300" height="100" alt="Storyblok + Astro">
|
|
4
4
|
</a>
|
|
5
5
|
<h1 align="center">@storyblok/astro</h1>
|
|
6
6
|
<p align="center">Astro integration for the <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro" target="_blank">Storyblok</a> Headless CMS.</p> <br />
|
|
@@ -73,6 +73,8 @@ storyblok({
|
|
|
73
73
|
apiOptions: {}, // storyblok-js-client options
|
|
74
74
|
components: {},
|
|
75
75
|
componentsDir: "src",
|
|
76
|
+
enableFallbackComponent: false,
|
|
77
|
+
customFallbackComponent: "",
|
|
76
78
|
useCustomApi: false,
|
|
77
79
|
});
|
|
78
80
|
```
|
|
@@ -130,7 +132,7 @@ components: {
|
|
|
130
132
|
>
|
|
131
133
|
> ```js
|
|
132
134
|
> storyblok({
|
|
133
|
-
> componentsDir: "
|
|
135
|
+
> componentsDir: "app",
|
|
134
136
|
> });
|
|
135
137
|
> ```
|
|
136
138
|
>
|
|
@@ -167,6 +169,10 @@ const { blok } = Astro.props
|
|
|
167
169
|
|
|
168
170
|
> Note: The `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro).
|
|
169
171
|
|
|
172
|
+
#### Using fallback components
|
|
173
|
+
|
|
174
|
+
By default, `@storyblok/astro` throws an error if a component is not implemented. Setting `enableFallbackComponent` to `true` bypasses that behavior, rendering a fallback component in the frontend instead. You can also use a custom fallback component by (for example) setting `customFallbackComponent: "storyblok/MyCustomFallback"`.
|
|
175
|
+
|
|
170
176
|
#### Using partial hydration
|
|
171
177
|
|
|
172
178
|
If you want to use partial hydration with any of the [frameworks supported by Astro](https://docs.astro.build/en/guides/integrations-guide/#article), follow these steps:
|
package/StoryblokComponent.astro
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import components from "virtual:storyblok-components";
|
|
3
|
+
import options from "virtual:storyblok-options";
|
|
3
4
|
import camelcase from "camelcase";
|
|
4
5
|
import type { SbBlokData } from "./types";
|
|
6
|
+
import type { AstroComponentFactory } from "astro/dist/runtime/server";
|
|
5
7
|
|
|
6
8
|
interface Props {
|
|
7
9
|
blok: SbBlokData;
|
|
@@ -11,21 +13,25 @@ interface Props {
|
|
|
11
13
|
const { blok, ...props } = Astro.props;
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
|
-
* convert blok components to camel case to match vite-plugin-storyblok
|
|
16
|
+
* convert blok components to camel case to match vite-plugin-storyblok-components
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
let key = camelcase(blok.component);
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* TODO: Add support for a placeholder component as a fallback?
|
|
22
|
-
*/
|
|
23
|
-
throw new Error(
|
|
24
|
-
`Component could not be found for blok "${blok.component}"! Is it defined in astro.config.mjs?`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
20
|
+
const componentFound: boolean = key in components;
|
|
21
|
+
|
|
22
|
+
let Component: AstroComponentFactory;
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
if (!componentFound) {
|
|
25
|
+
if (!options.enableFallbackComponent)
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Component could not be found for blok "${blok.component}"! Is it defined in astro.config.mjs?`
|
|
28
|
+
);
|
|
29
|
+
else {
|
|
30
|
+
Component = components["FallbackComponent"];
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
Component = components[key];
|
|
34
|
+
}
|
|
29
35
|
---
|
|
30
36
|
|
|
31
37
|
<Component blok={blok} {...props} />
|
package/dist/storyblok-astro.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(g=typeof globalThis<"u"?globalThis:g||self,p(g.storyblokAstro={}))})(this,function(g){"use strict";function p(r,e,t){const o="virtual:storyblok-init",a="\0"+o;return{name:"vite-plugin-storyblok-init",async resolveId(s){if(s===o)return a},async load(s){if(s===a)return`
|
|
2
2
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
3
3
|
const { storyblokApi } = storyblokInit({
|
|
4
4
|
accessToken: "${r}",
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
apiOptions: ${JSON.stringify(t)},
|
|
7
7
|
});
|
|
8
8
|
export const storyblokApiInstance = storyblokApi;
|
|
9
|
-
`}}}const x=/[\p{Lu}]/u,R=/[\p{Ll}]/u,
|
|
9
|
+
`}}}const x=/[\p{Lu}]/u,R=/[\p{Ll}]/u,k=/^[\p{Lu}](?![\p{Lu}])/gu,$=/([\p{Alpha}\p{N}_]|$)/u,b=/[_.\- ]+/,N=new RegExp("^"+b.source),v=new RegExp(b.source+$.source,"gu"),I=new RegExp("\\d+"+$.source,"gu"),O=(r,e,t,o)=>{let a=!1,s=!1,i=!1,f=!1;for(let n=0;n<r.length;n++){const l=r[n];f=n>2?r[n-3]==="-":!0,a&&x.test(l)?(r=r.slice(0,n)+"-"+r.slice(n),a=!1,i=s,s=!0,n++):s&&i&&R.test(l)&&(!f||o)?(r=r.slice(0,n-1)+"-"+r.slice(n-1),i=s,s=!1,a=!0):(a=e(l)===l&&t(l)!==l,i=s,s=t(l)===l&&e(l)!==l)}return r},L=(r,e)=>(k.lastIndex=0,r.replace(k,t=>e(t))),M=(r,e)=>(v.lastIndex=0,I.lastIndex=0,r.replace(v,(t,o)=>e(o)).replace(I,t=>e(t)));function w(r,e){if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(r)?r=r.map(s=>s.trim()).filter(s=>s.length).join("-"):r=r.trim(),r.length===0)return"";const t=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),o=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return r.length===1?b.test(r)?"":e.pascalCase?o(r):t(r):(r!==t(r)&&(r=O(r,t,o,e.preserveConsecutiveUppercase)),r=r.replace(N,""),r=e.preserveConsecutiveUppercase?L(r,t):t(r),e.pascalCase&&(r=o(r.charAt(0))+r.slice(1)),M(r,o))}function P(r,e,t,o){const a="virtual:storyblok-components",s="\0"+a;return{name:"vite-plugin-storyblok-components",async resolveId(i){if(i===a)return s},async load(i){if(i===s){const f=[],n=[];for await(const[c,d]of Object.entries(e)){const h=await this.resolve("/"+r+"/"+d+".astro");if(h)f.push(`import ${w(c)} from "${h.id}"`);else if(t)n.push(c);else throw new Error(`Component could not be found for blok "${c}"! Does "${"/"+r+"/"+d}.astro" exist?`)}let l="";if(t)if(l=",FallbackComponent",o){const c=await this.resolve("/"+r+"/"+o+".astro");if(!c)throw new Error(`Custom fallback component could not be found. Does "${"/"+r+"/"+o}.astro" exist?`);f.push(`import FallbackComponent from "${c.id}"`)}else f.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro';");return`${f.join(";")};export default {${Object.keys(e).filter(c=>!n.includes(c)).map(c=>w(c)).join(",")}${l}}`}}}}function _(r){const e="virtual:storyblok-options",t="\0"+e;return{name:"vite-plugin-storyblok-options",async resolveId(o){if(o===e)return t},async load(o){if(o===t)return`export default ${JSON.stringify(r)}`}}}let T=!1;const A=[],z=r=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=a=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}T?a():A.push(a)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=r,o.id="storyblok-javascript-bridge",o.onerror=a=>t(a),o.onload=a=>{A.forEach(s=>s()),T=!0,e(a)},document.getElementsByTagName("head")[0].appendChild(o)});var D=Object.defineProperty,U=(r,e,t)=>e in r?D(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e,t)=>(U(r,typeof e!="symbol"?e+"":e,t),t);const F=function(r,e){const t={};for(const o in r){const a=r[o];e.indexOf(o)>-1&&a!==null&&(t[o]=a)}return t},q=r=>r==="email",B=()=>({singleTag:"hr"}),J=()=>({tag:"blockquote"}),K=()=>({tag:"ul"}),V=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),G=()=>({singleTag:"br"}),W=r=>({tag:`h${r.attrs.level}`}),Y=r=>({singleTag:[{tag:"img",attrs:F(r.attrs,["src","alt","title"])}]}),H=()=>({tag:"li"}),Q=()=>({tag:"ol"}),X=()=>({tag:"p"}),Z=r=>({tag:[{tag:"span",attrs:{["data-type"]:"emoji",["data-name"]:r.attrs.name,emoji:r.attrs.emoji}}]}),ee=()=>({tag:"b"}),te=()=>({tag:"strike"}),re=()=>({tag:"u"}),oe=()=>({tag:"strong"}),se=()=>({tag:"code"}),ae=()=>({tag:"i"}),ie=r=>{const e={...r.attrs},{linktype:t="url"}=r.attrs;if(q(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const o in e.custom)e[o]=e.custom[o];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},ne=r=>({tag:[{tag:"span",attrs:r.attrs}]}),le=()=>({tag:"sub"}),ce=()=>({tag:"sup"}),ge=r=>({tag:[{tag:"span",attrs:r.attrs}]}),ue=r=>({tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color};`}}]}),fe=r=>({tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color}`}}]}),E={nodes:{horizontal_rule:B,blockquote:J,bullet_list:K,code_block:V,hard_break:G,heading:W,image:Y,list_item:H,ordered_list:Q,paragraph:X,emoji:Z},marks:{bold:ee,strike:te,underline:re,strong:oe,code:se,italic:ae,link:ie,styled:ne,subscript:le,superscript:ce,anchor:ge,highlight:ue,textStyle:fe}},de=function(r){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,o=RegExp(t.source);return r&&o.test(r)?r.replace(t,a=>e[a]):r};class j{constructor(e){C(this,"marks"),C(this,"nodes"),e||(e=E),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1}){if(e&&e.content&&Array.isArray(e.content)){let o="";return e.content.forEach(a=>{o+=this.renderNode(a)}),t.optimizeImages?this.optimizeImages(o,t.optimizeImages):o}return console.warn("The render method must receive an object with a content field, which is an array"),""}optimizeImages(e,t){let o=0,a=0,s="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(s+=`width="${t.width}" `,o=t.width),typeof t.height=="number"&&t.height>0&&(s+=`height="${t.height}" `,a=t.height),(t.loading==="lazy"||t.loading==="eager")&&(s+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(s+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i="/filters"+i))),s.length>0&&(e=e.replace(/<img/g,`<img ${s.trim()}`));const f=o>0||a>0||i.length>0?`${o}x${a}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${f}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,n=>{var l,c;const d=n.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(d&&d.length>0){const h={srcset:(l=t.srcset)==null?void 0:l.map(u=>{if(typeof u=="number")return`//${d}/m/${u}x0${i} ${u}w`;if(typeof u=="object"&&u.length===2){let y=0,S=0;return typeof u[0]=="number"&&(y=u[0]),typeof u[1]=="number"&&(S=u[1]),`//${d}/m/${y}x${S}${i} ${y}w`}}).join(", "),sizes:(c=t.sizes)==null?void 0:c.map(u=>u).join(", ")};let m="";return h.srcset&&(m+=`srcset="${h.srcset}" `),h.sizes&&(m+=`sizes="${h.sizes}" `),n.replace(/<img/g,`<img ${m.trim()}`)}return n})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(a=>{const s=this.getMatchingMark(a);s&&t.push(this.renderOpeningTag(s.tag))});const o=this.getMatchingNode(e);return o&&o.tag&&t.push(this.renderOpeningTag(o.tag)),e.content?e.content.forEach(a=>{t.push(this.renderNode(a))}):e.text?t.push(de(e.text)):o&&o.singleTag?t.push(this.renderTag(o.singleTag," /")):o&&o.html?t.push(o.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),o&&o.tag&&t.push(this.renderClosingTag(o.tag)),e.marks&&e.marks.slice(0).reverse().forEach(a=>{const s=this.getMatchingMark(a);s&&t.push(this.renderClosingTag(s.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(o=>{if(o.constructor===String)return`<${o}${t}>`;{let a=`<${o.tag}`;if(o.attrs)for(const s in o.attrs){const i=o.attrs[s];i!==null&&(a+=` ${s}="${i}"`)}return`${a}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}const he=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const e=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let pe;const be="https://app.storyblok.com/f/storyblok-v2-latest.js",me=(r,e)=>{r.addNode("blok",t=>{let o="";return t.attrs.body.forEach(a=>{o+=e(a.component,a)}),{html:o}})},ye=(r,e,t)=>{let o=t||pe;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return r===""?"":r?(e&&(o=new j(e.schema),e.resolver&&me(o,e.resolver)),o.render(r)):(console.warn(`${r} 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`),"")},ke=()=>z(be);function $e(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function ve(r,e){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return ye(r,e,t)}function Ie(r){const e={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,...r};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:o})=>{o({vite:{plugins:[p(e.accessToken,e.useCustomApi,e.apiOptions),P(e.componentsDir,e.components,e.enableFallbackComponent,e.customFallbackComponent),_(e)]}}),t("page-ssr",`
|
|
12
12
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
13
13
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
14
14
|
`),e.bridge&&t("page",`
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
`)}}}}
|
|
26
|
+
`)}}}}g.RichTextResolver=j,g.RichTextSchema=E,g.default=Ie,g.loadStoryblokBridge=ke,g.renderRichText=ve,g.storyblokEditable=he,g.useStoryblokApi=$e,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/storyblok-astro.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
1
|
+
function T(r, e, t) {
|
|
2
|
+
const o = "virtual:storyblok-init", a = "\0" + o;
|
|
3
3
|
return {
|
|
4
4
|
name: "vite-plugin-storyblok-init",
|
|
5
|
-
async resolveId(
|
|
6
|
-
if (
|
|
5
|
+
async resolveId(s) {
|
|
6
|
+
if (s === o)
|
|
7
7
|
return a;
|
|
8
8
|
},
|
|
9
|
-
async load(
|
|
10
|
-
if (
|
|
9
|
+
async load(s) {
|
|
10
|
+
if (s === a)
|
|
11
11
|
return `
|
|
12
12
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
13
13
|
const { storyblokApi } = storyblokInit({
|
|
@@ -20,14 +20,14 @@ function A(r, e, t) {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
let a = !1,
|
|
25
|
-
for (let
|
|
26
|
-
const
|
|
27
|
-
|
|
23
|
+
const A = /[\p{Lu}]/u, j = /[\p{Ll}]/u, y = /^[\p{Lu}](?![\p{Lu}])/gu, E = /([\p{Alpha}\p{N}_]|$)/u, b = /[_.\- ]+/, x = new RegExp("^" + b.source), k = new RegExp(b.source + E.source, "gu"), $ = new RegExp("\\d+" + E.source, "gu"), S = (r, e, t, o) => {
|
|
24
|
+
let a = !1, s = !1, l = !1, u = !1;
|
|
25
|
+
for (let i = 0; i < r.length; i++) {
|
|
26
|
+
const n = r[i];
|
|
27
|
+
u = i > 2 ? r[i - 3] === "-" : !0, a && A.test(n) ? (r = r.slice(0, i) + "-" + r.slice(i), a = !1, l = s, s = !0, i++) : s && l && j.test(n) && (!u || o) ? (r = r.slice(0, i - 1) + "-" + r.slice(i - 1), l = s, s = !1, a = !0) : (a = e(n) === n && t(n) !== n, l = s, s = t(n) === n && e(n) !== n);
|
|
28
28
|
}
|
|
29
29
|
return r;
|
|
30
|
-
}, R = (r, e) => (y.lastIndex = 0, r.replace(y, (t) => e(t))), N = (r, e) => (k.lastIndex = 0, $.lastIndex = 0, r.replace(k, (t,
|
|
30
|
+
}, R = (r, e) => (y.lastIndex = 0, r.replace(y, (t) => e(t))), N = (r, e) => (k.lastIndex = 0, $.lastIndex = 0, r.replace(k, (t, o) => e(o)).replace($, (t) => e(t)));
|
|
31
31
|
function v(r, e) {
|
|
32
32
|
if (!(typeof r == "string" || Array.isArray(r)))
|
|
33
33
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
@@ -35,37 +35,71 @@ function v(r, e) {
|
|
|
35
35
|
pascalCase: !1,
|
|
36
36
|
preserveConsecutiveUppercase: !1,
|
|
37
37
|
...e
|
|
38
|
-
}, Array.isArray(r) ? r = r.map((
|
|
38
|
+
}, Array.isArray(r) ? r = r.map((s) => s.trim()).filter((s) => s.length).join("-") : r = r.trim(), r.length === 0)
|
|
39
39
|
return "";
|
|
40
|
-
const t = e.locale === !1 ? (
|
|
41
|
-
return r.length === 1 ?
|
|
40
|
+
const t = 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 r.length === 1 ? b.test(r) ? "" : e.pascalCase ? o(r) : t(r) : (r !== t(r) && (r = S(r, t, o, e.preserveConsecutiveUppercase)), r = r.replace(x, ""), r = e.preserveConsecutiveUppercase ? R(r, t) : t(r), e.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), N(r, o));
|
|
42
42
|
}
|
|
43
|
-
function L(r, e) {
|
|
44
|
-
const
|
|
43
|
+
function L(r, e, t, o) {
|
|
44
|
+
const a = "virtual:storyblok-components", s = "\0" + a;
|
|
45
45
|
return {
|
|
46
46
|
name: "vite-plugin-storyblok-components",
|
|
47
|
-
async resolveId(
|
|
48
|
-
if (
|
|
47
|
+
async resolveId(l) {
|
|
48
|
+
if (l === a)
|
|
49
49
|
return s;
|
|
50
50
|
},
|
|
51
|
-
async load(
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
54
|
-
for await (const [
|
|
55
|
-
const
|
|
56
|
-
"/" + r + "/" +
|
|
51
|
+
async load(l) {
|
|
52
|
+
if (l === s) {
|
|
53
|
+
const u = [], i = [];
|
|
54
|
+
for await (const [c, f] of Object.entries(e)) {
|
|
55
|
+
const d = await this.resolve(
|
|
56
|
+
"/" + r + "/" + f + ".astro"
|
|
57
57
|
);
|
|
58
|
-
if (
|
|
58
|
+
if (d)
|
|
59
|
+
u.push(`import ${v(c)} from "${d.id}"`);
|
|
60
|
+
else if (t)
|
|
61
|
+
i.push(c);
|
|
62
|
+
else
|
|
59
63
|
throw new Error(
|
|
60
|
-
`Component could not be found for blok "${
|
|
64
|
+
`Component could not be found for blok "${c}"! Does "${"/" + r + "/" + f}.astro" exist?`
|
|
61
65
|
);
|
|
62
|
-
o.push(`import ${v(i)} from "${n.id}"`);
|
|
63
66
|
}
|
|
64
|
-
|
|
67
|
+
let n = "";
|
|
68
|
+
if (t)
|
|
69
|
+
if (n = ",FallbackComponent", o) {
|
|
70
|
+
const c = await this.resolve(
|
|
71
|
+
"/" + r + "/" + o + ".astro"
|
|
72
|
+
);
|
|
73
|
+
if (!c)
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Custom fallback component could not be found. Does "${"/" + r + "/" + o}.astro" exist?`
|
|
76
|
+
);
|
|
77
|
+
u.push(
|
|
78
|
+
`import FallbackComponent from "${c.id}"`
|
|
79
|
+
);
|
|
80
|
+
} else
|
|
81
|
+
u.push(
|
|
82
|
+
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro';"
|
|
83
|
+
);
|
|
84
|
+
return `${u.join(";")};export default {${Object.keys(e).filter((c) => !i.includes(c)).map((c) => v(c)).join(",")}${n}}`;
|
|
65
85
|
}
|
|
66
86
|
}
|
|
67
87
|
};
|
|
68
88
|
}
|
|
89
|
+
function O(r) {
|
|
90
|
+
const e = "virtual:storyblok-options", t = "\0" + e;
|
|
91
|
+
return {
|
|
92
|
+
name: "vite-plugin-storyblok-options",
|
|
93
|
+
async resolveId(o) {
|
|
94
|
+
if (o === e)
|
|
95
|
+
return t;
|
|
96
|
+
},
|
|
97
|
+
async load(o) {
|
|
98
|
+
if (o === t)
|
|
99
|
+
return `export default ${JSON.stringify(r)}`;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
69
103
|
let I = !1;
|
|
70
104
|
const w = [], z = (r) => new Promise((e, t) => {
|
|
71
105
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (a) => {
|
|
@@ -76,22 +110,22 @@ const w = [], z = (r) => new Promise((e, t) => {
|
|
|
76
110
|
I ? a() : w.push(a);
|
|
77
111
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
78
112
|
return;
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
w.forEach((
|
|
82
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
113
|
+
const o = document.createElement("script");
|
|
114
|
+
o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (a) => t(a), o.onload = (a) => {
|
|
115
|
+
w.forEach((s) => s()), I = !0, e(a);
|
|
116
|
+
}, document.getElementsByTagName("head")[0].appendChild(o);
|
|
83
117
|
});
|
|
84
|
-
var
|
|
118
|
+
var M = Object.defineProperty, P = (r, e, t) => e in r ? M(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, C = (r, e, t) => (P(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
85
119
|
const _ = function(r, e) {
|
|
86
120
|
const t = {};
|
|
87
|
-
for (const
|
|
88
|
-
const a = r[
|
|
89
|
-
e.indexOf(
|
|
121
|
+
for (const o in r) {
|
|
122
|
+
const a = r[o];
|
|
123
|
+
e.indexOf(o) > -1 && a !== null && (t[o] = a);
|
|
90
124
|
}
|
|
91
125
|
return t;
|
|
92
|
-
},
|
|
126
|
+
}, D = (r) => r === "email", U = () => ({
|
|
93
127
|
singleTag: "hr"
|
|
94
|
-
}),
|
|
128
|
+
}), F = () => ({
|
|
95
129
|
tag: "blockquote"
|
|
96
130
|
}), q = () => ({
|
|
97
131
|
tag: "ul"
|
|
@@ -103,9 +137,9 @@ const _ = function(r, e) {
|
|
|
103
137
|
attrs: r.attrs
|
|
104
138
|
}
|
|
105
139
|
]
|
|
106
|
-
}),
|
|
140
|
+
}), J = () => ({
|
|
107
141
|
singleTag: "br"
|
|
108
|
-
}),
|
|
142
|
+
}), K = (r) => ({
|
|
109
143
|
tag: `h${r.attrs.level}`
|
|
110
144
|
}), V = (r) => ({
|
|
111
145
|
singleTag: [
|
|
@@ -116,11 +150,11 @@ const _ = function(r, e) {
|
|
|
116
150
|
]
|
|
117
151
|
}), G = () => ({
|
|
118
152
|
tag: "li"
|
|
119
|
-
}), K = () => ({
|
|
120
|
-
tag: "ol"
|
|
121
153
|
}), W = () => ({
|
|
154
|
+
tag: "ol"
|
|
155
|
+
}), Y = () => ({
|
|
122
156
|
tag: "p"
|
|
123
|
-
}),
|
|
157
|
+
}), H = (r) => ({
|
|
124
158
|
tag: [
|
|
125
159
|
{
|
|
126
160
|
tag: "span",
|
|
@@ -131,23 +165,23 @@ const _ = function(r, e) {
|
|
|
131
165
|
}
|
|
132
166
|
}
|
|
133
167
|
]
|
|
134
|
-
}), H = () => ({
|
|
135
|
-
tag: "b"
|
|
136
168
|
}), Q = () => ({
|
|
137
|
-
tag: "
|
|
169
|
+
tag: "b"
|
|
138
170
|
}), X = () => ({
|
|
139
|
-
tag: "
|
|
171
|
+
tag: "strike"
|
|
140
172
|
}), Z = () => ({
|
|
141
|
-
tag: "
|
|
173
|
+
tag: "u"
|
|
142
174
|
}), ee = () => ({
|
|
143
|
-
tag: "
|
|
175
|
+
tag: "strong"
|
|
144
176
|
}), te = () => ({
|
|
177
|
+
tag: "code"
|
|
178
|
+
}), re = () => ({
|
|
145
179
|
tag: "i"
|
|
146
|
-
}),
|
|
180
|
+
}), oe = (r) => {
|
|
147
181
|
const e = { ...r.attrs }, { linktype: t = "url" } = r.attrs;
|
|
148
|
-
if (
|
|
149
|
-
for (const
|
|
150
|
-
e[
|
|
182
|
+
if (D(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
|
|
183
|
+
for (const o in e.custom)
|
|
184
|
+
e[o] = e.custom[o];
|
|
151
185
|
delete e.custom;
|
|
152
186
|
}
|
|
153
187
|
return {
|
|
@@ -165,9 +199,9 @@ const _ = function(r, e) {
|
|
|
165
199
|
attrs: r.attrs
|
|
166
200
|
}
|
|
167
201
|
]
|
|
168
|
-
}), oe = () => ({
|
|
169
|
-
tag: "sub"
|
|
170
202
|
}), ae = () => ({
|
|
203
|
+
tag: "sub"
|
|
204
|
+
}), le = () => ({
|
|
171
205
|
tag: "sup"
|
|
172
206
|
}), ie = (r) => ({
|
|
173
207
|
tag: [
|
|
@@ -185,7 +219,7 @@ const _ = function(r, e) {
|
|
|
185
219
|
}
|
|
186
220
|
}
|
|
187
221
|
]
|
|
188
|
-
}),
|
|
222
|
+
}), ce = (r) => ({
|
|
189
223
|
tag: [
|
|
190
224
|
{
|
|
191
225
|
tag: "span",
|
|
@@ -194,48 +228,48 @@ const _ = function(r, e) {
|
|
|
194
228
|
}
|
|
195
229
|
}
|
|
196
230
|
]
|
|
197
|
-
}),
|
|
231
|
+
}), ge = {
|
|
198
232
|
nodes: {
|
|
199
|
-
horizontal_rule:
|
|
200
|
-
blockquote:
|
|
233
|
+
horizontal_rule: U,
|
|
234
|
+
blockquote: F,
|
|
201
235
|
bullet_list: q,
|
|
202
236
|
code_block: B,
|
|
203
|
-
hard_break:
|
|
204
|
-
heading:
|
|
237
|
+
hard_break: J,
|
|
238
|
+
heading: K,
|
|
205
239
|
image: V,
|
|
206
240
|
list_item: G,
|
|
207
|
-
ordered_list:
|
|
208
|
-
paragraph:
|
|
209
|
-
emoji:
|
|
241
|
+
ordered_list: W,
|
|
242
|
+
paragraph: Y,
|
|
243
|
+
emoji: H
|
|
210
244
|
},
|
|
211
245
|
marks: {
|
|
212
|
-
bold:
|
|
213
|
-
strike:
|
|
214
|
-
underline:
|
|
215
|
-
strong:
|
|
216
|
-
code:
|
|
217
|
-
italic:
|
|
218
|
-
link:
|
|
246
|
+
bold: Q,
|
|
247
|
+
strike: X,
|
|
248
|
+
underline: Z,
|
|
249
|
+
strong: ee,
|
|
250
|
+
code: te,
|
|
251
|
+
italic: re,
|
|
252
|
+
link: oe,
|
|
219
253
|
styled: se,
|
|
220
|
-
subscript:
|
|
221
|
-
superscript:
|
|
254
|
+
subscript: ae,
|
|
255
|
+
superscript: le,
|
|
222
256
|
anchor: ie,
|
|
223
257
|
highlight: ne,
|
|
224
|
-
textStyle:
|
|
258
|
+
textStyle: ce
|
|
225
259
|
}
|
|
226
|
-
},
|
|
260
|
+
}, ue = function(r) {
|
|
227
261
|
const e = {
|
|
228
262
|
"&": "&",
|
|
229
263
|
"<": "<",
|
|
230
264
|
">": ">",
|
|
231
265
|
'"': """,
|
|
232
266
|
"'": "'"
|
|
233
|
-
}, t = /[&<>"']/g,
|
|
234
|
-
return r &&
|
|
267
|
+
}, t = /[&<>"']/g, o = RegExp(t.source);
|
|
268
|
+
return r && o.test(r) ? r.replace(t, (a) => e[a]) : r;
|
|
235
269
|
};
|
|
236
|
-
class
|
|
270
|
+
class fe {
|
|
237
271
|
constructor(e) {
|
|
238
|
-
|
|
272
|
+
C(this, "marks"), C(this, "nodes"), e || (e = ge), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
239
273
|
}
|
|
240
274
|
addNode(e, t) {
|
|
241
275
|
this.nodes[e] = t;
|
|
@@ -245,69 +279,69 @@ class ue {
|
|
|
245
279
|
}
|
|
246
280
|
render(e, t = { optimizeImages: !1 }) {
|
|
247
281
|
if (e && e.content && Array.isArray(e.content)) {
|
|
248
|
-
let
|
|
282
|
+
let o = "";
|
|
249
283
|
return e.content.forEach((a) => {
|
|
250
|
-
|
|
251
|
-
}), t.optimizeImages ? this.optimizeImages(
|
|
284
|
+
o += this.renderNode(a);
|
|
285
|
+
}), t.optimizeImages ? this.optimizeImages(o, t.optimizeImages) : o;
|
|
252
286
|
}
|
|
253
287
|
return console.warn(
|
|
254
288
|
"The render method must receive an object with a content field, which is an array"
|
|
255
289
|
), "";
|
|
256
290
|
}
|
|
257
291
|
optimizeImages(e, t) {
|
|
258
|
-
let
|
|
259
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (
|
|
260
|
-
const
|
|
292
|
+
let o = 0, a = 0, s = "", l = "";
|
|
293
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (s += `width="${t.width}" `, o = t.width), typeof t.height == "number" && t.height > 0 && (s += `height="${t.height}" `, a = t.height), (t.loading === "lazy" || t.loading === "eager") && (s += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (s += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (l += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (l += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (l += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (l += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (l += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (l += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (l += `:rotate(${t.filters.rotate})`), l.length > 0 && (l = "/filters" + l))), s.length > 0 && (e = e.replace(/<img/g, `<img ${s.trim()}`));
|
|
294
|
+
const u = o > 0 || a > 0 || l.length > 0 ? `${o}x${a}${l}` : "";
|
|
261
295
|
return e = e.replace(
|
|
262
296
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
263
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
264
|
-
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (
|
|
265
|
-
var
|
|
266
|
-
const
|
|
297
|
+
`a.storyblok.com/f/$1/$2.$3/m/${u}`
|
|
298
|
+
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
|
|
299
|
+
var n, c;
|
|
300
|
+
const f = i.match(
|
|
267
301
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
268
302
|
);
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
srcset: (
|
|
272
|
-
if (typeof
|
|
273
|
-
return `//${
|
|
274
|
-
if (typeof
|
|
275
|
-
let
|
|
276
|
-
return typeof
|
|
303
|
+
if (f && f.length > 0) {
|
|
304
|
+
const d = {
|
|
305
|
+
srcset: (n = t.srcset) == null ? void 0 : n.map((g) => {
|
|
306
|
+
if (typeof g == "number")
|
|
307
|
+
return `//${f}/m/${g}x0${l} ${g}w`;
|
|
308
|
+
if (typeof g == "object" && g.length === 2) {
|
|
309
|
+
let p = 0, m = 0;
|
|
310
|
+
return typeof g[0] == "number" && (p = g[0]), typeof g[1] == "number" && (m = g[1]), `//${f}/m/${p}x${m}${l} ${p}w`;
|
|
277
311
|
}
|
|
278
312
|
}).join(", "),
|
|
279
|
-
sizes: (
|
|
313
|
+
sizes: (c = t.sizes) == null ? void 0 : c.map((g) => g).join(", ")
|
|
280
314
|
};
|
|
281
|
-
let
|
|
282
|
-
return
|
|
315
|
+
let h = "";
|
|
316
|
+
return d.srcset && (h += `srcset="${d.srcset}" `), d.sizes && (h += `sizes="${d.sizes}" `), i.replace(/<img/g, `<img ${h.trim()}`);
|
|
283
317
|
}
|
|
284
|
-
return
|
|
318
|
+
return i;
|
|
285
319
|
})), e;
|
|
286
320
|
}
|
|
287
321
|
renderNode(e) {
|
|
288
322
|
const t = [];
|
|
289
323
|
e.marks && e.marks.forEach((a) => {
|
|
290
|
-
const
|
|
291
|
-
|
|
324
|
+
const s = this.getMatchingMark(a);
|
|
325
|
+
s && t.push(this.renderOpeningTag(s.tag));
|
|
292
326
|
});
|
|
293
|
-
const
|
|
294
|
-
return
|
|
327
|
+
const o = this.getMatchingNode(e);
|
|
328
|
+
return o && o.tag && t.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((a) => {
|
|
295
329
|
t.push(this.renderNode(a));
|
|
296
|
-
}) : e.text ? t.push(
|
|
297
|
-
const
|
|
298
|
-
|
|
330
|
+
}) : e.text ? t.push(ue(e.text)) : o && o.singleTag ? t.push(this.renderTag(o.singleTag, " /")) : o && o.html ? t.push(o.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), o && o.tag && t.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((a) => {
|
|
331
|
+
const s = this.getMatchingMark(a);
|
|
332
|
+
s && t.push(this.renderClosingTag(s.tag));
|
|
299
333
|
}), t.join("");
|
|
300
334
|
}
|
|
301
335
|
renderTag(e, t) {
|
|
302
|
-
return e.constructor === String ? `<${e}${t}>` : e.map((
|
|
303
|
-
if (
|
|
304
|
-
return `<${
|
|
336
|
+
return e.constructor === String ? `<${e}${t}>` : e.map((o) => {
|
|
337
|
+
if (o.constructor === String)
|
|
338
|
+
return `<${o}${t}>`;
|
|
305
339
|
{
|
|
306
|
-
let a = `<${
|
|
307
|
-
if (
|
|
308
|
-
for (const
|
|
309
|
-
const
|
|
310
|
-
|
|
340
|
+
let a = `<${o.tag}`;
|
|
341
|
+
if (o.attrs)
|
|
342
|
+
for (const s in o.attrs) {
|
|
343
|
+
const l = o.attrs[s];
|
|
344
|
+
l !== null && (a += ` ${s}="${l}"`);
|
|
311
345
|
}
|
|
312
346
|
return `${a}${t}>`;
|
|
313
347
|
}
|
|
@@ -357,32 +391,32 @@ const me = (r) => {
|
|
|
357
391
|
"data-blok-uid": e.id + "-" + e.uid
|
|
358
392
|
};
|
|
359
393
|
};
|
|
360
|
-
let
|
|
361
|
-
const
|
|
394
|
+
let de;
|
|
395
|
+
const he = "https://app.storyblok.com/f/storyblok-v2-latest.js", pe = (r, e) => {
|
|
362
396
|
r.addNode("blok", (t) => {
|
|
363
|
-
let
|
|
397
|
+
let o = "";
|
|
364
398
|
return t.attrs.body.forEach((a) => {
|
|
365
|
-
|
|
399
|
+
o += e(a.component, a);
|
|
366
400
|
}), {
|
|
367
|
-
html:
|
|
401
|
+
html: o
|
|
368
402
|
};
|
|
369
403
|
});
|
|
370
|
-
},
|
|
371
|
-
let
|
|
372
|
-
if (!
|
|
404
|
+
}, be = (r, e, t) => {
|
|
405
|
+
let o = t || de;
|
|
406
|
+
if (!o) {
|
|
373
407
|
console.error(
|
|
374
408
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
375
409
|
);
|
|
376
410
|
return;
|
|
377
411
|
}
|
|
378
|
-
return r === "" ? "" : r ? (e && (
|
|
412
|
+
return r === "" ? "" : r ? (e && (o = new fe(e.schema), e.resolver && pe(o, e.resolver)), o.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
379
413
|
|
|
380
414
|
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
|
|
381
|
-
},
|
|
382
|
-
function
|
|
415
|
+
}, ye = () => z(he);
|
|
416
|
+
function ke() {
|
|
383
417
|
return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
|
|
384
418
|
}
|
|
385
|
-
function
|
|
419
|
+
function $e(r, e) {
|
|
386
420
|
const t = globalThis.storyblokApiInstance.richTextResolver;
|
|
387
421
|
if (!t) {
|
|
388
422
|
console.error(
|
|
@@ -390,31 +424,35 @@ function ke(r, e) {
|
|
|
390
424
|
);
|
|
391
425
|
return;
|
|
392
426
|
}
|
|
393
|
-
return
|
|
427
|
+
return be(r, e, t);
|
|
394
428
|
}
|
|
395
|
-
function
|
|
429
|
+
function ve(r) {
|
|
396
430
|
const e = {
|
|
397
431
|
useCustomApi: !1,
|
|
398
432
|
bridge: !0,
|
|
399
433
|
componentsDir: "src",
|
|
434
|
+
enableFallbackComponent: !1,
|
|
400
435
|
...r
|
|
401
436
|
};
|
|
402
437
|
return {
|
|
403
438
|
name: "@storyblok/astro",
|
|
404
439
|
hooks: {
|
|
405
|
-
"astro:config:setup": ({ injectScript: t, updateConfig:
|
|
406
|
-
|
|
440
|
+
"astro:config:setup": ({ injectScript: t, updateConfig: o }) => {
|
|
441
|
+
o({
|
|
407
442
|
vite: {
|
|
408
443
|
plugins: [
|
|
409
|
-
|
|
444
|
+
T(
|
|
410
445
|
e.accessToken,
|
|
411
446
|
e.useCustomApi,
|
|
412
447
|
e.apiOptions
|
|
413
448
|
),
|
|
414
449
|
L(
|
|
415
450
|
e.componentsDir,
|
|
416
|
-
e.components
|
|
417
|
-
|
|
451
|
+
e.components,
|
|
452
|
+
e.enableFallbackComponent,
|
|
453
|
+
e.customFallbackComponent
|
|
454
|
+
),
|
|
455
|
+
O(e)
|
|
418
456
|
]
|
|
419
457
|
}
|
|
420
458
|
}), t(
|
|
@@ -444,11 +482,11 @@ function $e(r) {
|
|
|
444
482
|
};
|
|
445
483
|
}
|
|
446
484
|
export {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
485
|
+
fe as RichTextResolver,
|
|
486
|
+
ge as RichTextSchema,
|
|
487
|
+
ve as default,
|
|
488
|
+
ye as loadStoryblokBridge,
|
|
489
|
+
$e as renderRichText,
|
|
452
490
|
me as storyblokEditable,
|
|
453
|
-
|
|
491
|
+
ke as useStoryblokApi
|
|
454
492
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -38,6 +38,15 @@ export type IntegrationOptions = {
|
|
|
38
38
|
* The directory containing your Astro components are. Defaults to "src".
|
|
39
39
|
*/
|
|
40
40
|
componentsDir?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Show a fallback component in your frontend if a component is not registered properly.
|
|
43
|
+
*/
|
|
44
|
+
enableFallbackComponent?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Provide a path to a custom fallback component, e.g. "storyblok/customFallback".
|
|
47
|
+
* Please note: the path takes into account the `componentsDir` option.
|
|
48
|
+
*/
|
|
49
|
+
customFallbackComponent?: string;
|
|
41
50
|
};
|
|
42
51
|
export default function storyblokIntegration(options: IntegrationOptions): AstroIntegration;
|
|
43
52
|
export * from "./types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/astro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
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",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"import": "./dist/storyblok-astro.mjs",
|
|
14
14
|
"require": "./dist/storyblok-astro.js"
|
|
15
15
|
},
|
|
16
|
-
"./StoryblokComponent.astro": "./StoryblokComponent.astro"
|
|
16
|
+
"./StoryblokComponent.astro": "./StoryblokComponent.astro",
|
|
17
|
+
"./FallbackComponent.astro": "./FallbackComponent.astro"
|
|
17
18
|
},
|
|
18
19
|
"types": "./dist/types/index.d.ts",
|
|
19
20
|
"scripts": {
|
|
@@ -35,11 +36,11 @@
|
|
|
35
36
|
"@cypress/vite-dev-server": "^5.0.5",
|
|
36
37
|
"@rollup/plugin-dynamic-import-vars": "^2.0.3",
|
|
37
38
|
"@types/node": "18.15.11",
|
|
38
|
-
"astro": "2.
|
|
39
|
+
"astro": "2.3.0",
|
|
39
40
|
"cypress": "^12.9.0",
|
|
40
41
|
"eslint-plugin-cypress": "^2.13.2",
|
|
41
42
|
"start-server-and-test": "^2.0.0",
|
|
42
|
-
"typescript": "5.0.
|
|
43
|
+
"typescript": "5.0.4",
|
|
43
44
|
"vite": "^4.2.1",
|
|
44
45
|
"vite-plugin-dts": "^2.2.0"
|
|
45
46
|
},
|