ts-glitter 16.2.6 → 16.2.8
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/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/glitter-base/global/currency.d.ts +19 -0
- package/lowcode/glitter-base/global/currency.js.map +1 -0
- package/lowcode/glitter-base/global/global-user.d.ts +5 -0
- package/lowcode/glitter-base/global/global-user.js.map +1 -1
- package/lowcode/glitter-base/global/language.d.ts +22 -0
- package/lowcode/glitter-base/global/language.js.map +1 -0
- package/lowcode/glitter-base/route/shopping.d.ts +28 -2
- package/lowcode/glitter-base/route/shopping.js.map +1 -1
- package/lowcode/glitterBundle/api/base.js.map +1 -1
- package/package.json +1 -1
- package/src/api-public/services/shopping.js +1 -0
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +1 -0
- package/src/helper/glitter-util.d.ts +4 -1
- package/src/helper/glitter-util.js +3 -2
- package/src/helper/glitter-util.js.map +1 -1
- package/src/helper/glitter-util.ts +4 -3
- package/src/index.js +178 -117
- package/src/index.js.map +1 -1
- package/src/index.ts +121 -66
- package/src/seo-config.d.ts +1 -6
- package/src/seo-config.js +69 -73
- package/src/seo-config.js.map +1 -1
- package/src/seo-config.ts +96 -97
package/src/seo-config.ts
CHANGED
|
@@ -52,12 +52,25 @@ export class SeoConfig {
|
|
|
52
52
|
)[0] ?? {};
|
|
53
53
|
const colJson = extractCols(cols);
|
|
54
54
|
const urlCode = decodeURI((cf.page as string).split('/')[1]);
|
|
55
|
-
const colData = colJson.find((item:
|
|
55
|
+
const colData = colJson.find((item: any) => {
|
|
56
|
+
if (item.language_data && item.language_data[cf.language]) {
|
|
57
|
+
return item.language_data[cf.language].seo.domain === urlCode || item.title === urlCode
|
|
58
|
+
} else {
|
|
59
|
+
return (item.code === urlCode) || item.title === urlCode;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
56
62
|
if (colData) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
if (colData.language_data && colData.language_data[cf.language]) {
|
|
64
|
+
cf.data.page_config.seo.title = colData.language_data[cf.language].seo.title || urlCode;
|
|
65
|
+
cf.data.page_config.seo.content = colData.language_data[cf.language].seo.content;
|
|
66
|
+
cf.data.tag = cf.page
|
|
67
|
+
} else {
|
|
68
|
+
cf.data.page_config.seo.title = colData.seo_title || urlCode;
|
|
69
|
+
cf.data.page_config.seo.content = colData.seo_content;
|
|
70
|
+
cf.data.page_config.seo.keywords = colData.seo_keywords;
|
|
71
|
+
cf.data.tag = cf.page
|
|
72
|
+
}
|
|
73
|
+
cf.data.page_config.seo.image = colData.seo_image;
|
|
61
74
|
}
|
|
62
75
|
}
|
|
63
76
|
|
|
@@ -106,14 +119,15 @@ export class SeoConfig {
|
|
|
106
119
|
return html`location.href = '/';`;
|
|
107
120
|
}
|
|
108
121
|
}
|
|
122
|
+
|
|
109
123
|
//商品頁面SEO
|
|
110
|
-
public static async productSEO(cf:{
|
|
111
|
-
data:any,
|
|
112
|
-
language:any,
|
|
113
|
-
appName:string,
|
|
114
|
-
product_id:string,
|
|
115
|
-
page:string
|
|
116
|
-
}){
|
|
124
|
+
public static async productSEO(cf: {
|
|
125
|
+
data: any,
|
|
126
|
+
language: any,
|
|
127
|
+
appName: string,
|
|
128
|
+
product_id: string,
|
|
129
|
+
page: string
|
|
130
|
+
}) {
|
|
117
131
|
const product_domain = (cf.page as string).split('/')[1];
|
|
118
132
|
const pd = await new Shopping(cf.appName, undefined).getProduct(
|
|
119
133
|
product_domain
|
|
@@ -130,36 +144,35 @@ export class SeoConfig {
|
|
|
130
144
|
language: cf.language,
|
|
131
145
|
}
|
|
132
146
|
);
|
|
133
|
-
|
|
134
|
-
console.log(`pd==>`,pd)
|
|
135
147
|
if (pd.data.content) {
|
|
136
148
|
pd.data.content.language_data = pd.data.content.language_data ?? {};
|
|
137
149
|
const productSeo = (pd.data.content.language_data[cf.language] && pd.data.content.language_data[cf.language].seo) || (pd.data.content.seo ?? {});
|
|
138
|
-
const language_data=pd.data.content.language_data
|
|
150
|
+
const language_data = pd.data.content.language_data
|
|
139
151
|
cf.data.page_config = cf.data.page_config ?? {};
|
|
140
152
|
cf.data.page_config.seo = cf.data.page_config.seo ?? {};
|
|
141
153
|
cf.data.page_config.seo.title = productSeo.title;
|
|
142
|
-
cf.data.page_config.seo.image = (language_data && language_data[cf.language] && language_data.preview_image && language_data.preview_image[0]
|
|
154
|
+
cf.data.page_config.seo.image = (language_data && language_data[cf.language] && language_data.preview_image && language_data.preview_image[0]) || pd.data.content.preview_image[0];
|
|
143
155
|
cf.data.page_config.seo.content = productSeo.content;
|
|
144
156
|
cf.data.tag = cf.page;
|
|
145
157
|
}
|
|
146
158
|
}
|
|
159
|
+
|
|
147
160
|
//網誌頁面SEO
|
|
148
|
-
public static async articleSeo(cf:{
|
|
149
|
-
article:any,
|
|
150
|
-
page:string,
|
|
151
|
-
appName:string,
|
|
152
|
-
data:any,
|
|
153
|
-
language:any
|
|
154
|
-
}){
|
|
161
|
+
public static async articleSeo(cf: {
|
|
162
|
+
article: any,
|
|
163
|
+
page: string,
|
|
164
|
+
appName: string,
|
|
165
|
+
data: any,
|
|
166
|
+
language: any
|
|
167
|
+
}) {
|
|
155
168
|
cf.article = cf.article || (cf.page as any).split('/')[1];
|
|
156
169
|
let query = [`(content->>'$.type'='article')`, `(content->>'$.tag'='${cf.article}')`];
|
|
157
170
|
const article: any = await new UtDatabase(cf.appName, `t_manager_post`).querySql(query, {
|
|
158
171
|
page: 0,
|
|
159
172
|
limit: 1,
|
|
160
173
|
});
|
|
161
|
-
cf.data.page_config =
|
|
162
|
-
cf.data.page_config.seo =
|
|
174
|
+
cf.data.page_config = cf.data.page_config ?? {};
|
|
175
|
+
cf.data.page_config.seo = cf.data.page_config.seo ?? {};
|
|
163
176
|
if (article.data[0]) {
|
|
164
177
|
cf.data.tag = cf.page;
|
|
165
178
|
if (article.data[0].content.language_data && article.data[0].content.language_data[cf.language]) {
|
|
@@ -173,8 +186,9 @@ export class SeoConfig {
|
|
|
173
186
|
}
|
|
174
187
|
}
|
|
175
188
|
}
|
|
189
|
+
|
|
176
190
|
//取得多國語言
|
|
177
|
-
public static async language(store_info:any,req:any){
|
|
191
|
+
public static async language(store_info: any, req: any) {
|
|
178
192
|
function checkIncludes(lan: string) {
|
|
179
193
|
return store_info.language_setting.support.includes(lan);
|
|
180
194
|
}
|
|
@@ -204,63 +218,66 @@ export class SeoConfig {
|
|
|
204
218
|
return store_info.language_setting.def;
|
|
205
219
|
}
|
|
206
220
|
}
|
|
221
|
+
|
|
207
222
|
//FB像素
|
|
208
|
-
public static fbCode(FBCode:any){
|
|
223
|
+
public static fbCode(FBCode: any) {
|
|
209
224
|
return FBCode && FBCode.pixel
|
|
210
225
|
? html`<!-- Meta Pixel Code -->
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
226
|
+
<script>
|
|
227
|
+
!(function (f, b, e, v, n, t, s) {
|
|
228
|
+
if (f.fbq) return;
|
|
229
|
+
n = f.fbq = function () {
|
|
230
|
+
n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);
|
|
231
|
+
};
|
|
232
|
+
if (!f._fbq) f._fbq = n;
|
|
233
|
+
n.push = n;
|
|
234
|
+
n.loaded = !0;
|
|
235
|
+
n.version = '2.0';
|
|
236
|
+
n.queue = [];
|
|
237
|
+
t = b.createElement(e);
|
|
238
|
+
t.async = !0;
|
|
239
|
+
t.src = v;
|
|
240
|
+
s = b.getElementsByTagName(e)[0];
|
|
241
|
+
s.parentNode.insertBefore(t, s);
|
|
242
|
+
})(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
|
243
|
+
fbq('init', '${FBCode.pixel}');
|
|
244
|
+
fbq('track', 'PageView');
|
|
245
|
+
</script>
|
|
246
|
+
<noscript><img height="1" width="1" style="display:none"
|
|
247
|
+
src="https://www.facebook.com/tr?id=617830100580621&ev=PageView&noscript=1"/>
|
|
248
|
+
</noscript>
|
|
249
|
+
<!-- End Meta Pixel Code -->`
|
|
235
250
|
: ''
|
|
236
251
|
}
|
|
252
|
+
|
|
237
253
|
//GA標籤
|
|
238
|
-
public static gTag(g_tag:any[]){
|
|
254
|
+
public static gTag(g_tag: any[]) {
|
|
239
255
|
return (g_tag || [])
|
|
240
256
|
.map((dd: any) => {
|
|
241
257
|
return html`<!-- Google tag (gtag.js) -->
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
<!-- Google Tag Manager -->
|
|
259
|
+
<script>
|
|
260
|
+
(function (w, d, s, l, i) {
|
|
261
|
+
w[l] = w[l] || [];
|
|
262
|
+
w[l].push({
|
|
263
|
+
'gtm.start': new Date().getTime(),
|
|
264
|
+
event: 'gtm.js',
|
|
265
|
+
});
|
|
266
|
+
var f = d.getElementsByTagName(s)[0],
|
|
267
|
+
j = d.createElement(s),
|
|
268
|
+
dl = l != 'dataLayer' ? '&l=' + l : '';
|
|
269
|
+
j.async = true;
|
|
270
|
+
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
|
|
271
|
+
f.parentNode.insertBefore(j, f);
|
|
272
|
+
})(window, document, 'script', 'dataLayer', '${dd.code}');
|
|
273
|
+
</script>
|
|
274
|
+
<!-- End Google Tag Manager -->`;
|
|
259
275
|
})
|
|
260
276
|
.join('')
|
|
261
277
|
}
|
|
278
|
+
|
|
262
279
|
//GA追蹤
|
|
263
|
-
public static gA4(ga4:any[]){
|
|
280
|
+
public static gA4(ga4: any[]) {
|
|
264
281
|
return (ga4 || [])
|
|
265
282
|
.map((dd: any) => {
|
|
266
283
|
return html`<!-- Google tag (gtag.js) -->
|
|
@@ -286,32 +303,21 @@ export class SeoConfig {
|
|
|
286
303
|
|
|
287
304
|
|
|
288
305
|
export function extractCols(data: {
|
|
289
|
-
value:
|
|
290
|
-
code: string;
|
|
291
|
-
array: { code: string }[];
|
|
292
|
-
}[];
|
|
306
|
+
value: any[];
|
|
293
307
|
updated_at: Date;
|
|
294
308
|
}) {
|
|
295
|
-
|
|
309
|
+
let items: any = [];
|
|
296
310
|
const updated_at = new Date(data.updated_at).toISOString().replace(/\.\d{3}Z$/, '+00:00');
|
|
297
311
|
data.value.map((item: any) => {
|
|
298
312
|
items.push({
|
|
299
|
-
|
|
300
|
-
updated_at
|
|
301
|
-
seo_title: item.seo_title,
|
|
302
|
-
seo_image: item.seo_image,
|
|
303
|
-
seo_content: item.seo_content,
|
|
313
|
+
...item,
|
|
314
|
+
updated_at
|
|
304
315
|
});
|
|
305
316
|
if (item.array && item.array.length > 0) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
seo_title: child.seo_title,
|
|
311
|
-
seo_image: child.seo_image,
|
|
312
|
-
seo_content: child.seo_content,
|
|
313
|
-
});
|
|
314
|
-
});
|
|
317
|
+
items = items.concat(extractCols({
|
|
318
|
+
value: item.array,
|
|
319
|
+
updated_at: data.updated_at
|
|
320
|
+
}))
|
|
315
321
|
}
|
|
316
322
|
});
|
|
317
323
|
return items;
|
|
@@ -320,15 +326,8 @@ export function extractCols(data: {
|
|
|
320
326
|
export function extractProds(data: any) {
|
|
321
327
|
const items: any = [];
|
|
322
328
|
data.map((item: any) => {
|
|
323
|
-
const code = (() => {
|
|
324
|
-
try {
|
|
325
|
-
return item.content.seo.domain;
|
|
326
|
-
} catch (error) {
|
|
327
|
-
return '';
|
|
328
|
-
}
|
|
329
|
-
})();
|
|
330
329
|
const updated_at = new Date(item.updated_time).toISOString().replace(/\.\d{3}Z$/, '+00:00');
|
|
331
|
-
items.push({
|
|
330
|
+
items.push({items});
|
|
332
331
|
});
|
|
333
332
|
return items;
|
|
334
333
|
}
|