webstudio 0.129.0 → 0.131.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/lib/cli.js CHANGED
@@ -267,7 +267,9 @@ import {
267
267
  generateRemixRoute,
268
268
  generateRemixParams,
269
269
  generateResourcesLoader,
270
- collectionComponent
270
+ collectionComponent,
271
+ generatePageMeta,
272
+ executeExpression
271
273
  } from "@webstudio-is/react-sdk";
272
274
  import {
273
275
  createScope,
@@ -525,7 +527,7 @@ var prebuild = async (options) => {
525
527
  },
526
528
  {
527
529
  assetBaseUrl,
528
- atomic: siteData.build.pages.settings?.atomicStyles ?? true
530
+ atomic: siteData.build.pages.compiler?.atomicStyles ?? true
529
531
  }
530
532
  );
531
533
  await ensureFileInPath(join4(generatedDir, "index.css"), cssText);
@@ -541,6 +543,8 @@ var prebuild = async (options) => {
541
543
  "useState",
542
544
  "Fragment",
543
545
  "useResource",
546
+ "PageMeta",
547
+ "createPageMeta",
544
548
  "PageData",
545
549
  "Asset",
546
550
  "fontAssets",
@@ -583,8 +587,7 @@ var prebuild = async (options) => {
583
587
  }
584
588
  const pageData = siteDataByPage[pageId];
585
589
  const renderedPageData = {
586
- project: siteData.build.pages.meta,
587
- page: pageData.page
590
+ project: siteData.build.pages.meta
588
591
  };
589
592
  const rootInstanceId = pageData.page.rootInstanceId;
590
593
  const instances = new Map(pageData.build.instances);
@@ -632,6 +635,7 @@ var prebuild = async (options) => {
632
635
  import { Fragment, useState } from "react";
633
636
  import type { Asset, ImageAsset, ProjectMeta } from "@webstudio-is/sdk";
634
637
  import { useResource } from "@webstudio-is/react-sdk";
638
+ import type { PageMeta } from "@webstudio-is/react-sdk";
635
639
  ${componentImports}
636
640
  import type { PageData } from "~/routes/_index";
637
641
  export const fontAssets: Asset[] = ${JSON.stringify(fontAssets)}
@@ -642,6 +646,8 @@ export const user: { email: string | null } | undefined = ${JSON.stringify(
642
646
  )};
643
647
  export const projectId = "${siteData.build.projectId}";
644
648
 
649
+ ${generatePageMeta({ scope, page: pageData.page, dataSources })}
650
+
645
651
  ${pageComponent}
646
652
 
647
653
  export { Page }
@@ -677,7 +683,9 @@ ${utilsExport}
677
683
  `
678
684
  export const sitemap = ${JSON.stringify(
679
685
  {
680
- pages: siteData.pages.filter((page) => page.meta.excludePageFromSearch !== true).map((page) => ({
686
+ pages: siteData.pages.filter(
687
+ (page) => executeExpression(page.meta.excludePageFromSearch) !== true
688
+ ).map((page) => ({
681
689
  path: page.path,
682
690
  lastModified: siteData.build.updatedAt
683
691
  }))
@@ -860,7 +868,7 @@ import makeCLI from "yargs";
860
868
  // package.json
861
869
  var package_default = {
862
870
  name: "webstudio",
863
- version: "0.129.0",
871
+ version: "0.131.0",
864
872
  description: "Webstudio CLI",
865
873
  author: "Webstudio <github@webstudio.is>",
866
874
  homepage: "https://webstudio.is",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webstudio",
3
- "version": "0.129.0",
3
+ "version": "0.131.0",
4
4
  "description": "Webstudio CLI",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -28,21 +28,21 @@
28
28
  "title-case": "^4.1.0",
29
29
  "yargs": "^17.7.2",
30
30
  "zod": "^3.21.4",
31
- "@webstudio-is/http-client": "0.129.0",
32
- "@webstudio-is/react-sdk": "0.129.0",
33
- "@webstudio-is/sdk": "0.129.0",
34
- "@webstudio-is/image": "0.129.0",
35
- "@webstudio-is/sdk-components-react": "0.129.0",
36
- "@webstudio-is/sdk-components-react-remix": "0.129.0",
37
- "@webstudio-is/sdk-components-react-radix": "0.129.0"
31
+ "@webstudio-is/http-client": "0.131.0",
32
+ "@webstudio-is/react-sdk": "0.131.0",
33
+ "@webstudio-is/image": "0.131.0",
34
+ "@webstudio-is/sdk": "0.131.0",
35
+ "@webstudio-is/sdk-components-react-remix": "0.131.0",
36
+ "@webstudio-is/sdk-components-react-radix": "0.131.0",
37
+ "@webstudio-is/sdk-components-react": "0.131.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^18.17.1",
41
41
  "@types/prompts": "^2.4.5",
42
42
  "tsx": "^3.12.8",
43
43
  "typescript": "5.2.2",
44
- "@webstudio-is/form-handlers": "0.129.0",
45
- "@webstudio-is/tsconfig": "1.0.7"
44
+ "@webstudio-is/tsconfig": "1.0.7",
45
+ "@webstudio-is/form-handlers": "0.131.0"
46
46
  },
47
47
  "scripts": {
48
48
  "typecheck": "tsc",
@@ -8,7 +8,7 @@ import {
8
8
  json,
9
9
  } from "@remix-run/server-runtime";
10
10
  import { useLoaderData } from "@remix-run/react";
11
- import type { Page as PageType, ProjectMeta } from "@webstudio-is/sdk";
11
+ import type { ProjectMeta } from "@webstudio-is/sdk";
12
12
  import { ReactSdkContext } from "@webstudio-is/react-sdk";
13
13
  import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";
14
14
  import {
@@ -21,6 +21,7 @@ import {
21
21
  Page,
22
22
  imageAssets,
23
23
  getRemixParams,
24
+ getPageMeta,
24
25
  } from "../../../__generated__/_index";
25
26
  import { loadResources } from "../../../__generated__/_index.server";
26
27
  import css from "../__generated__/index.css";
@@ -28,12 +29,12 @@ import { assetBaseUrl, imageBaseUrl, imageLoader } from "~/constants.mjs";
28
29
 
29
30
  export type PageData = {
30
31
  project?: ProjectMeta;
31
- page: PageType;
32
32
  };
33
33
 
34
34
  export const loader = async (arg: LoaderArgs) => {
35
35
  const params = getRemixParams(arg.params);
36
36
  const resources = await loadResources({ params });
37
+ const pageMeta = getPageMeta({ params, resources });
37
38
 
38
39
  const host =
39
40
  arg.request.headers.get("x-forwarded-host") ||
@@ -54,6 +55,7 @@ export const loader = async (arg: LoaderArgs) => {
54
55
  excludeFromSearch: arg.context.EXCLUDE_FROM_SEARCH,
55
56
  params,
56
57
  resources,
58
+ pageMeta,
57
59
  },
58
60
  // No way for current information to change, so add cache for 10 minutes
59
61
  // In case of CRM Data, this should be set to 0
@@ -68,29 +70,32 @@ export const headers = () => {
68
70
  };
69
71
 
70
72
  export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {
71
- const { page, project } = pageData;
72
-
73
73
  const metas: ReturnType<V2_ServerRuntimeMetaFunction> = [];
74
+ if (data === undefined) {
75
+ return metas;
76
+ }
77
+ const { pageMeta } = data;
78
+ const { project } = pageData;
74
79
 
75
- if (data?.url) {
80
+ if (data.url) {
76
81
  metas.push({
77
82
  property: "og:url",
78
83
  content: data.url,
79
84
  });
80
85
  }
81
86
 
82
- if (page.title) {
83
- metas.push({ title: page.title });
87
+ if (pageMeta.title) {
88
+ metas.push({ title: pageMeta.title });
84
89
 
85
90
  metas.push({
86
91
  property: "og:title",
87
- content: page.title,
92
+ content: pageMeta.title,
88
93
  });
89
94
  }
90
95
 
91
96
  metas.push({ property: "og:type", content: "website" });
92
97
 
93
- const origin = `https://${data?.host}`;
98
+ const origin = `https://${data.host}`;
94
99
 
95
100
  if (project?.siteName) {
96
101
  metas.push({
@@ -107,47 +112,47 @@ export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {
107
112
  });
108
113
  }
109
114
 
110
- if (page.meta.excludePageFromSearch || data?.excludeFromSearch) {
115
+ if (pageMeta.excludePageFromSearch || data.excludeFromSearch) {
111
116
  metas.push({
112
117
  name: "robots",
113
118
  content: "noindex, nofollow",
114
119
  });
115
120
  }
116
121
 
117
- if (page.meta.description) {
122
+ if (pageMeta.description) {
118
123
  metas.push({
119
124
  name: "description",
120
- content: page.meta.description,
125
+ content: pageMeta.description,
121
126
  });
122
127
  metas.push({
123
128
  property: "og:description",
124
- content: page.meta.description,
129
+ content: pageMeta.description,
125
130
  });
126
131
  }
127
132
 
128
- if (page.meta.socialImageAssetId) {
133
+ if (pageMeta.socialImageAssetId) {
129
134
  const imageAsset = imageAssets.find(
130
- (asset) => asset.id === page.meta.socialImageAssetId
135
+ (asset) => asset.id === pageMeta.socialImageAssetId
131
136
  );
132
137
 
133
138
  if (imageAsset) {
134
139
  metas.push({
135
140
  property: "og:image",
136
- content: `https://${data?.host}${imageLoader({
141
+ content: `https://${data.host}${imageLoader({
137
142
  src: imageAsset.name,
138
143
  // Do not transform social image (not enough information do we need to do this)
139
144
  format: "raw",
140
145
  })}`,
141
146
  });
142
147
  }
148
+ } else if (pageMeta.socialImageUrl) {
149
+ metas.push({
150
+ property: "og:image",
151
+ content: pageMeta.socialImageUrl,
152
+ });
143
153
  }
144
154
 
145
- for (const customMeta of page.meta.custom ?? []) {
146
- if (customMeta.property.trim().length === 0) {
147
- continue;
148
- }
149
- metas.push(customMeta);
150
- }
155
+ metas.push(...pageMeta.custom);
151
156
 
152
157
  return metas;
153
158
  };
@@ -10,13 +10,13 @@
10
10
  "@remix-run/react": "^1.19.2",
11
11
  "@remix-run/server-runtime": "^1.19.2",
12
12
  "@remix-run/node": "^1.19.2",
13
- "@webstudio-is/react-sdk": "0.129.0",
14
- "@webstudio-is/sdk-components-react-radix": "0.129.0",
15
- "@webstudio-is/sdk-components-react-remix": "0.129.0",
16
- "@webstudio-is/sdk-components-react": "0.129.0",
17
- "@webstudio-is/form-handlers": "0.129.0",
18
- "@webstudio-is/image": "0.129.0",
19
- "@webstudio-is/sdk": "0.129.0",
13
+ "@webstudio-is/react-sdk": "0.131.0",
14
+ "@webstudio-is/sdk-components-react-radix": "0.131.0",
15
+ "@webstudio-is/sdk-components-react-remix": "0.131.0",
16
+ "@webstudio-is/sdk-components-react": "0.131.0",
17
+ "@webstudio-is/form-handlers": "0.131.0",
18
+ "@webstudio-is/image": "0.131.0",
19
+ "@webstudio-is/sdk": "0.131.0",
20
20
  "isbot": "^3.6.8",
21
21
  "react": "^18.2.0",
22
22
  "react-dom": "^18.2.0"