@gem-sdk/pages 1.53.0-dev.89 → 1.53.0-dev.93
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.
|
@@ -18,7 +18,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
18
18
|
slug,
|
|
19
19
|
slugType: pageType
|
|
20
20
|
};
|
|
21
|
-
const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
|
|
21
|
+
const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
|
|
22
22
|
fetcher([
|
|
23
23
|
core.PublishedThemePagesDocument,
|
|
24
24
|
variables
|
|
@@ -28,11 +28,21 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
28
28
|
]),
|
|
29
29
|
shopifyFetcher([
|
|
30
30
|
adapterShopify.ShopMetaDocument
|
|
31
|
+
]),
|
|
32
|
+
fetcher([
|
|
33
|
+
core.PublishedShopMetasDocument,
|
|
34
|
+
{
|
|
35
|
+
keys: [
|
|
36
|
+
'source_font'
|
|
37
|
+
]
|
|
38
|
+
}
|
|
31
39
|
])
|
|
32
40
|
]);
|
|
33
41
|
if (theme.status === 'rejected') {
|
|
34
42
|
throw new Error(theme.reason?.[0]);
|
|
35
43
|
}
|
|
44
|
+
const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
|
|
45
|
+
const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
|
|
36
46
|
const dataBuilder = theme.value.publishedThemePages?.[0];
|
|
37
47
|
const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
|
|
38
48
|
if (!dataBuilder) {
|
|
@@ -40,8 +50,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
40
50
|
}
|
|
41
51
|
const pageTemplate = normalize.parseBuilderTemplateV2(dataBuilder);
|
|
42
52
|
const [elementFontStyle, fontStyle, fallback, customFonts$1] = await Promise.all([
|
|
43
|
-
googleFonts.getFontStyleFromPageTemplate(pageTemplate),
|
|
44
|
-
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
53
|
+
googleFonts.getFontStyleFromPageTemplate(pageTemplate, sourceFont?.value),
|
|
54
|
+
googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data, sourceFont?.value),
|
|
45
55
|
getFallback.getFallbackV2(fetcher, pageTemplate),
|
|
46
56
|
customFonts.getCustomFonts(themePageCustomFonts)
|
|
47
57
|
]);
|
|
@@ -85,7 +85,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
|
85
85
|
return '';
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
const getFontFromGlobalStyle = (data)=>{
|
|
88
|
+
const getFontFromGlobalStyle = (data, sourceFont)=>{
|
|
89
89
|
if (!data) return '';
|
|
90
90
|
try {
|
|
91
91
|
const globalStyle = JSON.parse(data);
|
|
@@ -93,14 +93,14 @@ const getFontFromGlobalStyle = (data)=>{
|
|
|
93
93
|
const fonts = Object.entries(fontData).map(([, value])=>{
|
|
94
94
|
return value;
|
|
95
95
|
});
|
|
96
|
-
return getFonts(fonts);
|
|
96
|
+
return getFonts(fonts, undefined, undefined, sourceFont);
|
|
97
97
|
} catch {
|
|
98
98
|
return '';
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
async function getFontStyleFromPageTemplate(pageTemplate) {
|
|
101
|
+
async function getFontStyleFromPageTemplate(pageTemplate, sourceFont) {
|
|
102
102
|
const fontStyle = pageTemplate.map((sectionData)=>{
|
|
103
|
-
return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data));
|
|
103
|
+
return getFonts(genFonts.getFontsFromDataBuilder(sectionData.data), undefined, undefined, sourceFont);
|
|
104
104
|
});
|
|
105
105
|
return await Promise.all(fontStyle);
|
|
106
106
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublishedThemePagesDocument, StorePropertyDocument } from '@gem-sdk/core';
|
|
1
|
+
import { PublishedThemePagesDocument, StorePropertyDocument, PublishedShopMetasDocument } from '@gem-sdk/core';
|
|
2
2
|
import { ShopMetaDocument } from '@gem-sdk/adapter-shopify';
|
|
3
3
|
import { getFontStyleFromPageTemplate, getFontFromGlobalStyle } from '../google-fonts.js';
|
|
4
4
|
import { genCSS } from '../helpers/gen-css.js';
|
|
@@ -16,7 +16,7 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
16
16
|
slug,
|
|
17
17
|
slugType: pageType
|
|
18
18
|
};
|
|
19
|
-
const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
|
|
19
|
+
const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
|
|
20
20
|
fetcher([
|
|
21
21
|
PublishedThemePagesDocument,
|
|
22
22
|
variables
|
|
@@ -26,11 +26,21 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
26
26
|
]),
|
|
27
27
|
shopifyFetcher([
|
|
28
28
|
ShopMetaDocument
|
|
29
|
+
]),
|
|
30
|
+
fetcher([
|
|
31
|
+
PublishedShopMetasDocument,
|
|
32
|
+
{
|
|
33
|
+
keys: [
|
|
34
|
+
'source_font'
|
|
35
|
+
]
|
|
36
|
+
}
|
|
29
37
|
])
|
|
30
38
|
]);
|
|
31
39
|
if (theme.status === 'rejected') {
|
|
32
40
|
throw new Error(theme.reason?.[0]);
|
|
33
41
|
}
|
|
42
|
+
const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
|
|
43
|
+
const sourceFont = publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === 'source_font');
|
|
34
44
|
const dataBuilder = theme.value.publishedThemePages?.[0];
|
|
35
45
|
const themePageCustomFonts = theme.value?.publishedThemePages?.[0]?.themePageCustomFonts;
|
|
36
46
|
if (!dataBuilder) {
|
|
@@ -38,8 +48,8 @@ const getStaticPagePropsV2 = (fetcher, shopifyFetcher)=>async (slug)=>{
|
|
|
38
48
|
}
|
|
39
49
|
const pageTemplate = parseBuilderTemplateV2(dataBuilder);
|
|
40
50
|
const [elementFontStyle, fontStyle, fallback, customFonts] = await Promise.all([
|
|
41
|
-
getFontStyleFromPageTemplate(pageTemplate),
|
|
42
|
-
getFontFromGlobalStyle(dataBuilder?.pageStyle?.data),
|
|
51
|
+
getFontStyleFromPageTemplate(pageTemplate, sourceFont?.value),
|
|
52
|
+
getFontFromGlobalStyle(dataBuilder?.pageStyle?.data, sourceFont?.value),
|
|
43
53
|
getFallbackV2(fetcher, pageTemplate),
|
|
44
54
|
getCustomFonts(themePageCustomFonts)
|
|
45
55
|
]);
|
|
@@ -83,7 +83,7 @@ async function getFonts(fonts, option, isImportFontByUrl = true, fontType) {
|
|
|
83
83
|
return '';
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
const getFontFromGlobalStyle = (data)=>{
|
|
86
|
+
const getFontFromGlobalStyle = (data, sourceFont)=>{
|
|
87
87
|
if (!data) return '';
|
|
88
88
|
try {
|
|
89
89
|
const globalStyle = JSON.parse(data);
|
|
@@ -91,14 +91,14 @@ const getFontFromGlobalStyle = (data)=>{
|
|
|
91
91
|
const fonts = Object.entries(fontData).map(([, value])=>{
|
|
92
92
|
return value;
|
|
93
93
|
});
|
|
94
|
-
return getFonts(fonts);
|
|
94
|
+
return getFonts(fonts, undefined, undefined, sourceFont);
|
|
95
95
|
} catch {
|
|
96
96
|
return '';
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
async function getFontStyleFromPageTemplate(pageTemplate) {
|
|
99
|
+
async function getFontStyleFromPageTemplate(pageTemplate, sourceFont) {
|
|
100
100
|
const fontStyle = pageTemplate.map((sectionData)=>{
|
|
101
|
-
return getFonts(getFontsFromDataBuilder(sectionData.data));
|
|
101
|
+
return getFonts(getFontsFromDataBuilder(sectionData.data), undefined, undefined, sourceFont);
|
|
102
102
|
});
|
|
103
103
|
return await Promise.all(fontStyle);
|
|
104
104
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -203,7 +203,7 @@ type FontOption = {
|
|
|
203
203
|
effect?: string;
|
|
204
204
|
};
|
|
205
205
|
declare function getFonts(fonts: FontItem[], option?: FontOption, isImportFontByUrl?: boolean, fontType?: string): Promise<string>;
|
|
206
|
-
declare const getFontFromGlobalStyle: (data?: string) => "" | Promise<string>;
|
|
206
|
+
declare const getFontFromGlobalStyle: (data?: string, sourceFont?: 'bunny' | 'google' | string) => "" | Promise<string>;
|
|
207
207
|
|
|
208
208
|
declare const getFontsFromDataBuilder: (dataBuilder: Record<string, any>) => FontItem[];
|
|
209
209
|
declare const getFontFromGroupSetting: (fonts: FontItem[], groupSetting: Record<string, any>) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "1.53.0-dev.
|
|
3
|
+
"version": "1.53.0-dev.93",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"next": "latest"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@gem-sdk/core": "1.53.0-dev.
|
|
29
|
+
"@gem-sdk/core": "1.53.0-dev.93",
|
|
30
30
|
"@gem-sdk/plugin-cookie-bar": "1.53.0-dev.4",
|
|
31
31
|
"@gem-sdk/plugin-quick-view": "1.53.0-dev.4",
|
|
32
32
|
"@gem-sdk/plugin-sticky-add-to-cart": "1.53.0-dev.4"
|