@storyblok/astro 4.1.0 → 4.1.1-next.1

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
@@ -27,13 +27,11 @@
27
27
  </a>
28
28
  </p>
29
29
 
30
- ## Live Demo
30
+ ## Kickstart a new project
31
+ Are you eager to dive into coding? **[Follow these steps to kickstart a new project with Storyblok and Astro](https://www.storyblok.com/technologies#astro?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)**, and get started in just a few minutes!
31
32
 
32
- If you are in a hurry, check out our official **[live demo](https://stackblitz.com/edit/astro-sdk-demo)** on StackBlitz.
33
-
34
- ## Usage
35
-
36
- > If you are first-time user of Storyblok, read the [Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro) guide to get a project ready in less than 5 minutes.
33
+ ## Ultimate Tutorial
34
+ Are you looking for a hands-on, step-by-step tutorial? The **[Astro Ultimate Tutorial](https://www.storyblok.com/tp/the-storyblok-astro-ultimate-tutorial?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)** has you covered! It provides comprehensive instructions on building a complete, multilingual website using Storyblok and Astro from start to finish.
37
35
 
38
36
  ## Installation
39
37
 
@@ -457,20 +455,21 @@ We extend our deepest gratitude to the [Astro](https://astro.build/) team, espec
457
455
 
458
456
  Our heartfelt thanks go to [Virtual Identity](https://www.virtual-identity.com/), one of our closest agency partners. The live preview feature owes its existence to the ingenuity and innovation of their team. Special recognition goes to their developer [Mario Hamann](https://github.com/mariohamann) for his pivotal live preview POC and continuous support.
459
457
 
460
- ## Related Links
461
-
462
- - **[Live Demo on Stackblitz](https://stackblitz.com/edit/astro-sdk-demo)**
463
- - **[Storyblok CLI](https://github.com/storyblok/storyblok)**: A simple CLI for scaffolding Storyblok projects.
458
+ ## Further Resources
464
459
 
465
- ## More Resources
460
+ - [Quick Start](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)
461
+ - [API Documentation](https://www.storyblok.com/docs/api?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)
462
+ - [Developer Tutorials](https://www.storyblok.com/tutorials?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)
463
+ - [Developer Guides](https://www.storyblok.com/docs/guide/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)
464
+ - [FAQs](https://www.storyblok.com/faqs?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)
466
465
 
467
- ### Support
466
+ ## Support
468
467
 
469
468
  - Bugs or Feature Requests? [Submit an issue](/../../issues/new);
470
469
  - Do you have questions about this SDK? Or would you like to join the growing community of `@storyblok/astro` users? [Join the Astro Discord Community](https://discord.com/channels/830184174198718474/1002802280267001858)
471
470
  - Do you have questions about Storyblok or do you need help? [Join the Storyblok Discord Community](https://discord.gg/jKrbAMz).
472
471
 
473
- ### Contributing
472
+ ## Contributing
474
473
 
475
474
  Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/master/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro).
476
475
  This project uses [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generating new versions by using commit messages. We use the Angular Convention to name the commits.
@@ -1051,11 +1051,9 @@ function In(o) {
1051
1051
  function Ht(o) {
1052
1052
  const r = {};
1053
1053
  return o.reduce((e, i) => {
1054
- if (i.type !== "Property")
1055
- return e;
1054
+ if (i.type !== "Property") return e;
1056
1055
  const { key: s, value: l } = i, { type: u } = l;
1057
- if (s.type !== "Identifier")
1058
- return e;
1056
+ if (s.type !== "Identifier") return e;
1059
1057
  if (u === "Literal")
1060
1058
  e[s.name] = l.value;
1061
1059
  else if (u === "ArrayExpression") {
@@ -1089,8 +1087,7 @@ function Sn(o, r) {
1089
1087
  },
1090
1088
  async transform(f, g) {
1091
1089
  var O;
1092
- if (g.includes("node_modules") && !g.includes("/pages/") || !f.includes("useStoryblok") || !((O = this.getModuleInfo(g).meta) != null && O.astro))
1093
- return;
1090
+ if (g.includes("node_modules") && !g.includes("/pages/") || !f.includes("useStoryblok") || !((O = this.getModuleInfo(g).meta) != null && O.astro)) return;
1094
1091
  const [, ..._] = g.split("src/pages/"), k = _.join("/").replace(".astro", ""), I = In(this.parse(f));
1095
1092
  B.length && (s = B.filter((w) => w.url !== k)), s.push({
1096
1093
  url: k,
@@ -1120,8 +1117,7 @@ async function En(o) {
1120
1117
  if (r === "input" && e) {
1121
1118
  const i = async () => {
1122
1119
  const l = await jn(e), u = document.body;
1123
- if (l.outerHTML === u.outerHTML)
1124
- return;
1120
+ if (l.outerHTML === u.outerHTML) return;
1125
1121
  const f = document.querySelector('[data-blok-focused="true"]');
1126
1122
  Cn(u, l, f);
1127
1123
  };
@@ -2,9 +2,22 @@ import { defineMiddleware } from "astro/middleware";
2
2
 
3
3
  export const onRequest = defineMiddleware(async ({ locals, request }, next) => {
4
4
  if (request["method"] === "POST") {
5
- const requestBody = await request.json();
6
- if (requestBody && requestBody["is_storyblok_preview"]) {
7
- locals["_storyblok_preview_data"] = requestBody;
5
+ const url = new URL(request.url);
6
+ //First do a basic check if its coming from within storyblok
7
+ const isStoryblokRequest =
8
+ url.searchParams.has("_storyblok") &&
9
+ url.searchParams.has("_storyblok_c");
10
+
11
+ if (isStoryblokRequest) {
12
+ try {
13
+ //Create a copy of the request
14
+ const requestBody = await request.clone().json();
15
+ if (requestBody && requestBody["is_storyblok_preview"]) {
16
+ locals["_storyblok_preview_data"] = requestBody;
17
+ }
18
+ } catch (error) {
19
+ console.error("Error reading request body:", error);
20
+ }
8
21
  }
9
22
  }
10
23
  return next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
- "version": "4.1.0",
3
+ "version": "4.1.1-next.1",
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",
@@ -64,13 +64,13 @@
64
64
  "@cypress/vite-dev-server": "^5.0.7",
65
65
  "@rollup/plugin-dynamic-import-vars": "^2.1.2",
66
66
  "@types/lodash.mergewith": "^4.6.9",
67
- "@types/node": "20.12.11",
68
- "astro": "^4.6.3",
69
- "cypress": "^13.8.1",
67
+ "@types/node": "20.14.9",
68
+ "astro": "^4.11.1",
69
+ "cypress": "^13.12.0",
70
70
  "eslint-plugin-cypress": "^3.2.0",
71
71
  "start-server-and-test": "^2.0.3",
72
72
  "typescript": "5.4.5",
73
- "vite": "^5.2.10",
73
+ "vite": "^5.3.1",
74
74
  "vite-plugin-dts": "^3.7.3"
75
75
  },
76
76
  "peerDependencies": {