webstudio 0.111.0 → 0.111.1-3138155.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 +10 -4
- package/package.json +10 -10
- package/templates/route-template.tsx +92 -14
- package/templates/vercel/app/constants.mjs +9 -5
package/lib/cli.js
CHANGED
|
@@ -456,6 +456,12 @@ var prebuild = async (options) => {
|
|
|
456
456
|
}
|
|
457
457
|
const assetsToDownload = [];
|
|
458
458
|
const fontAssets = [];
|
|
459
|
+
const imageAssets = [];
|
|
460
|
+
for (const asset of siteData.assets) {
|
|
461
|
+
if (asset.type === "image") {
|
|
462
|
+
imageAssets.push(asset);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
459
465
|
const appDomain = options.preview ? "wstd.work" : "wstd.io";
|
|
460
466
|
const assetBuildUrl = `https://${domain}.${appDomain}/cgi/asset/`;
|
|
461
467
|
const temporaryDir = await mkdtemp(join4(tmpdir(), "webstudio-"));
|
|
@@ -466,8 +472,6 @@ var prebuild = async (options) => {
|
|
|
466
472
|
for (const asset of siteData.assets) {
|
|
467
473
|
if (asset.type === "image") {
|
|
468
474
|
const imageSrc = imageLoader({
|
|
469
|
-
width: 16,
|
|
470
|
-
quality: 100,
|
|
471
475
|
src: asset.name,
|
|
472
476
|
format: "raw"
|
|
473
477
|
});
|
|
@@ -556,6 +560,7 @@ var prebuild = async (options) => {
|
|
|
556
560
|
}
|
|
557
561
|
const pageData = siteDataByPage[pathName];
|
|
558
562
|
const renderedPageData = {
|
|
563
|
+
site: siteData.build.pages.meta,
|
|
559
564
|
page: pageData.page
|
|
560
565
|
};
|
|
561
566
|
const rootInstanceId = pageData.page.rootInstanceId;
|
|
@@ -583,9 +588,10 @@ var prebuild = async (options) => {
|
|
|
583
588
|
|
|
584
589
|
import { type ReactNode, useState } from "react";
|
|
585
590
|
import type { PageData } from "~/routes/_index";
|
|
586
|
-
import type { Asset } from "@webstudio-is/sdk";
|
|
591
|
+
import type { Asset, ImageAsset, SiteMeta } from "@webstudio-is/sdk";
|
|
587
592
|
${componentImports}
|
|
588
593
|
export const fontAssets: Asset[] = ${JSON.stringify(fontAssets)}
|
|
594
|
+
export const imageAssets: ImageAsset[] = ${JSON.stringify(imageAssets)}
|
|
589
595
|
export const pageData: PageData = ${JSON.stringify(renderedPageData)};
|
|
590
596
|
export const user: { email: string | null } | undefined = ${JSON.stringify(
|
|
591
597
|
siteData.user
|
|
@@ -785,7 +791,7 @@ import makeCLI from "yargs";
|
|
|
785
791
|
// package.json
|
|
786
792
|
var package_default = {
|
|
787
793
|
name: "webstudio",
|
|
788
|
-
version: "0.111.0",
|
|
794
|
+
version: "0.111.1-3138155.0",
|
|
789
795
|
description: "Webstudio CLI",
|
|
790
796
|
author: "Webstudio <github@webstudio.is>",
|
|
791
797
|
homepage: "https://webstudio.is",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webstudio",
|
|
3
|
-
"version": "0.111.0",
|
|
3
|
+
"version": "0.111.1-3138155.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.111.0",
|
|
32
|
-
"@webstudio-is/image": "0.111.0",
|
|
33
|
-
"@webstudio-is/react-sdk": "0.111.0",
|
|
34
|
-
"@webstudio-is/sdk": "0.111.0",
|
|
35
|
-
"@webstudio-is/sdk-components-react": "0.111.0",
|
|
36
|
-
"@webstudio-is/sdk-components-react-radix": "0.111.0",
|
|
37
|
-
"@webstudio-is/sdk-components-react-remix": "0.111.0"
|
|
31
|
+
"@webstudio-is/http-client": "0.111.1-3138155.0",
|
|
32
|
+
"@webstudio-is/image": "0.111.1-3138155.0",
|
|
33
|
+
"@webstudio-is/react-sdk": "0.111.1-3138155.0",
|
|
34
|
+
"@webstudio-is/sdk": "0.111.1-3138155.0",
|
|
35
|
+
"@webstudio-is/sdk-components-react": "0.111.1-3138155.0",
|
|
36
|
+
"@webstudio-is/sdk-components-react-radix": "0.111.1-3138155.0",
|
|
37
|
+
"@webstudio-is/sdk-components-react-remix": "0.111.1-3138155.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.111.0",
|
|
45
|
-
"@webstudio-is/tsconfig": "1.0.
|
|
44
|
+
"@webstudio-is/form-handlers": "0.111.1-3138155.0",
|
|
45
|
+
"@webstudio-is/tsconfig": "1.0.8-3138155.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"typecheck": "tsc",
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
type LinksFunction,
|
|
5
5
|
type LinkDescriptor,
|
|
6
6
|
type ActionArgs,
|
|
7
|
+
type LoaderArgs,
|
|
7
8
|
json,
|
|
8
9
|
} from "@remix-run/server-runtime";
|
|
9
|
-
import type { Page as PageType } from "@webstudio-is/sdk";
|
|
10
|
+
import type { Page as PageType, SiteMeta } from "@webstudio-is/sdk";
|
|
10
11
|
import { ReactSdkContext } from "@webstudio-is/react-sdk";
|
|
11
12
|
import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";
|
|
12
13
|
import { Scripts, ScrollRestoration } from "@remix-run/react";
|
|
@@ -18,34 +19,78 @@ import {
|
|
|
18
19
|
pagesPaths,
|
|
19
20
|
formsProperties,
|
|
20
21
|
Page,
|
|
22
|
+
imageAssets,
|
|
21
23
|
} from "../__generated__/index";
|
|
22
24
|
import css from "../__generated__/index.css";
|
|
23
25
|
import { assetBaseUrl, imageBaseUrl, imageLoader } from "~/constants.mjs";
|
|
24
26
|
|
|
25
27
|
export type PageData = {
|
|
28
|
+
site?: SiteMeta;
|
|
26
29
|
page: PageType;
|
|
27
30
|
};
|
|
28
31
|
|
|
29
|
-
export const
|
|
30
|
-
const
|
|
32
|
+
export const loader = async (arg: LoaderArgs) => {
|
|
33
|
+
const host =
|
|
34
|
+
arg.request.headers.get("x-forwarded-host") ||
|
|
35
|
+
arg.request.headers.get("host") ||
|
|
36
|
+
"";
|
|
37
|
+
return json({ host });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const meta: V2_ServerRuntimeMetaFunction<typeof loader> = ({ data }) => {
|
|
41
|
+
const { page, site } = pageData;
|
|
42
|
+
|
|
31
43
|
const metas: ReturnType<V2_ServerRuntimeMetaFunction> = [
|
|
32
|
-
{ title: page
|
|
44
|
+
{ title: page.title },
|
|
45
|
+
{
|
|
46
|
+
property: "og:title",
|
|
47
|
+
content: page.title,
|
|
48
|
+
},
|
|
33
49
|
];
|
|
34
|
-
for (const [name, value] of Object.entries(page?.meta ?? {})) {
|
|
35
|
-
if (name.startsWith("og:")) {
|
|
36
|
-
metas.push({
|
|
37
|
-
property: name,
|
|
38
|
-
content: value,
|
|
39
|
-
});
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
50
|
|
|
51
|
+
if (site?.siteName) {
|
|
52
|
+
metas.push({
|
|
53
|
+
property: "og:site_name",
|
|
54
|
+
content: site.siteName,
|
|
55
|
+
});
|
|
43
56
|
metas.push({
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
"script:ld+json": {
|
|
58
|
+
"@context": "https://schema.org",
|
|
59
|
+
"@type": "Organization",
|
|
60
|
+
name: site.siteName,
|
|
61
|
+
url: `https://${data?.host}`,
|
|
62
|
+
},
|
|
46
63
|
});
|
|
47
64
|
}
|
|
48
65
|
|
|
66
|
+
if (page.meta.description) {
|
|
67
|
+
metas.push({
|
|
68
|
+
name: "description",
|
|
69
|
+
content: page.meta.description,
|
|
70
|
+
});
|
|
71
|
+
metas.push({
|
|
72
|
+
property: "og:description",
|
|
73
|
+
content: page.meta.description,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (page.meta.socialImageAssetId) {
|
|
78
|
+
const imageAsset = imageAssets.find(
|
|
79
|
+
(asset) => asset.id === page.meta.socialImageAssetId
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
if (imageAsset) {
|
|
83
|
+
metas.push({
|
|
84
|
+
property: "og:image",
|
|
85
|
+
content: imageLoader({
|
|
86
|
+
src: imageAsset.name,
|
|
87
|
+
// Do not transform social image (not enough information do we need to do this)
|
|
88
|
+
format: "raw",
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
49
94
|
return metas;
|
|
50
95
|
};
|
|
51
96
|
|
|
@@ -57,6 +102,39 @@ export const links: LinksFunction = () => {
|
|
|
57
102
|
href: css,
|
|
58
103
|
});
|
|
59
104
|
|
|
105
|
+
const { site } = pageData;
|
|
106
|
+
|
|
107
|
+
if (site?.faviconAssetId) {
|
|
108
|
+
const imageAsset = imageAssets.find(
|
|
109
|
+
(asset) => asset.id === site.faviconAssetId
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
if (imageAsset) {
|
|
113
|
+
result.push({
|
|
114
|
+
rel: "icon",
|
|
115
|
+
href: imageLoader({
|
|
116
|
+
src: imageAsset.name,
|
|
117
|
+
width: 128,
|
|
118
|
+
quality: 100,
|
|
119
|
+
format: "auto",
|
|
120
|
+
}),
|
|
121
|
+
type: undefined,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
result.push({
|
|
126
|
+
rel: "icon",
|
|
127
|
+
href: "/favicon.ico",
|
|
128
|
+
type: "image/x-icon",
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
result.push({
|
|
132
|
+
rel: "shortcut icon",
|
|
133
|
+
href: "/favicon.ico",
|
|
134
|
+
type: "image/x-icon",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
60
138
|
for (const asset of fontAssets) {
|
|
61
139
|
if (asset.type === "font") {
|
|
62
140
|
result.push({
|
|
@@ -8,18 +8,22 @@ export const imageBaseUrl = "/assets/";
|
|
|
8
8
|
/**
|
|
9
9
|
* @type {import("@webstudio-is/image").ImageLoader}
|
|
10
10
|
*/
|
|
11
|
-
export const imageLoader = (
|
|
11
|
+
export const imageLoader = (props) => {
|
|
12
12
|
if (process.env.NODE_ENV !== "production") {
|
|
13
|
-
return imageBaseUrl + src;
|
|
13
|
+
return imageBaseUrl + props.src;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (props.format === "raw") {
|
|
17
|
+
return imageBaseUrl + props.src;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
// https://vercel.com/blog/build-your-own-web-framework#automatic-image-optimization
|
|
17
21
|
return (
|
|
18
22
|
"/_vercel/image?url=" +
|
|
19
|
-
encodeURIComponent(imageBaseUrl + src) +
|
|
23
|
+
encodeURIComponent(imageBaseUrl + props.src) +
|
|
20
24
|
"&w=" +
|
|
21
|
-
width +
|
|
25
|
+
props.width +
|
|
22
26
|
"&q=" +
|
|
23
|
-
quality
|
|
27
|
+
props.quality
|
|
24
28
|
);
|
|
25
29
|
};
|