wgt-node-utils 1.2.65 → 1.2.67
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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.js +64 -47
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -161,6 +161,20 @@ class wgtNodeUtils {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
getVideoDomainByHostname = (hostname, ENV) => {
|
|
165
|
+
let self = this;
|
|
166
|
+
let needReplaceArr = ['pro', 'qa', 'dev', 'test', 'development'];
|
|
167
|
+
if (needReplaceArr.includes(ENV)) {
|
|
168
|
+
if (ENV === 'qa' || ENV === 'test') {
|
|
169
|
+
return `//video.test-static.beesads.com/game_video`
|
|
170
|
+
}
|
|
171
|
+
return `//video.enjoy4fun.com`;
|
|
172
|
+
} else {
|
|
173
|
+
const mainDomain = self.getMainDomainByHostname(hostname);
|
|
174
|
+
return `//video.${mainDomain}`;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
164
178
|
/***
|
|
165
179
|
* 通用头信息添加
|
|
166
180
|
* @res node端 返回头
|
|
@@ -865,9 +879,9 @@ class wgtNodeUtils {
|
|
|
865
879
|
* @param {string} applicationCategory: 应用分类 BrowserGame BrowserNews
|
|
866
880
|
* @param {string} genre: 游戏所属分类
|
|
867
881
|
*/
|
|
868
|
-
seoFun = ({ url, name, image, author, aggregateRating, description, hostname, languageList, lang, title, type, applicationCategory, genre }) => {
|
|
882
|
+
seoFun = ({ url, name, image, author, aggregateRating, description, hostname, languageList, lang, title, type, applicationCategory, genre,time }) => {
|
|
869
883
|
const pathWithoutLang = url ? url.replace(/(https?:\/\/[^/]+)\/en\b/, "$1") : '/';
|
|
870
|
-
const seoRenderLdJson = this.renderLdJson({ pathWithoutLang, name, image, author, aggregateRating, description, hostname, type,languageList, applicationCategory, genre });
|
|
884
|
+
const seoRenderLdJson = this.renderLdJson({ pathWithoutLang, name, image, author, aggregateRating, description, hostname, type, languageList, applicationCategory, genre,time });
|
|
871
885
|
const seoRenderAlternateLink = this.renderAlternateLink({ languageList, url, pathWithoutLang });
|
|
872
886
|
const seoraphAndTwitterFun = this.graphAndTwitterFun({ image, url, title, hostname, description, lang, pathWithoutLang });
|
|
873
887
|
const seoContent = {
|
|
@@ -897,63 +911,66 @@ class wgtNodeUtils {
|
|
|
897
911
|
* @param applicationCategory: 应用分类 BrowserGame BrowserNews
|
|
898
912
|
* @param genre: 游戏所属分类
|
|
899
913
|
*/
|
|
900
|
-
renderLdJson = ({ url, name, image, author, aggregateRating, description, hostname, type, languageList, applicationCategory, genre }) => {
|
|
901
|
-
if (!
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
let inLanguage = [];
|
|
905
|
-
if (languageList) {
|
|
906
|
-
inLanguage = languageList.map(item => {
|
|
907
|
-
return item.code;
|
|
908
|
-
});
|
|
914
|
+
renderLdJson = ({ url, name, image, author, aggregateRating, description, hostname, type, languageList, applicationCategory, genre, time }) => {
|
|
915
|
+
if (!url || !name) {
|
|
916
|
+
console.warn('renderLdJson: missing required fields (url, name)');
|
|
917
|
+
return null;
|
|
909
918
|
}
|
|
919
|
+
|
|
920
|
+
const currentType = type || 'WebApplication';
|
|
921
|
+
const inLanguage = languageList ? languageList.map(item => item.code) : [];
|
|
922
|
+
const organizationUrl = `https://${hostname}`;
|
|
923
|
+
|
|
910
924
|
const ld = {
|
|
911
|
-
'@context': 'https://schema.org/',
|
|
912
|
-
'@type':
|
|
913
|
-
'name': name,
|
|
914
|
-
'author': {
|
|
915
|
-
'@type': 'Organization',
|
|
916
|
-
'name': author
|
|
917
|
-
},
|
|
918
|
-
'image': image,
|
|
925
|
+
'@context': 'https://schema.org/',
|
|
926
|
+
'@type': currentType,
|
|
927
|
+
'name': name,
|
|
919
928
|
'description': description,
|
|
920
|
-
'potentialAction': {
|
|
921
|
-
'@type': 'SearchAction',
|
|
922
|
-
'target': `https://${hostname}/search/{search_term_string}`,
|
|
923
|
-
'query-input': 'required name=search_term_string'
|
|
924
|
-
},
|
|
925
|
-
'inLanguage': inLanguage,
|
|
926
929
|
'url': url,
|
|
927
|
-
'
|
|
928
|
-
'
|
|
929
|
-
|
|
930
|
-
'
|
|
931
|
-
'
|
|
932
|
-
'priceCurrency': 'USD'
|
|
930
|
+
'image': image,
|
|
931
|
+
'publisher': {
|
|
932
|
+
'@type': 'Organization',
|
|
933
|
+
'name': author,
|
|
934
|
+
'url': organizationUrl
|
|
933
935
|
},
|
|
934
|
-
|
|
935
|
-
featureList: [
|
|
936
|
-
'No download required',
|
|
937
|
-
'Instant use in browser',
|
|
938
|
-
'Thousands of free content',
|
|
939
|
-
'Daily updates',
|
|
940
|
-
'Mobile compatible'
|
|
941
|
-
],
|
|
942
|
-
isAccessibleForFree: true,
|
|
943
|
-
"publisher": {
|
|
936
|
+
'author': {
|
|
944
937
|
'@type': 'Organization',
|
|
945
938
|
'name': author,
|
|
946
|
-
'url':
|
|
939
|
+
'url': organizationUrl
|
|
947
940
|
}
|
|
948
941
|
};
|
|
949
|
-
|
|
950
|
-
if (
|
|
951
|
-
ld.
|
|
942
|
+
|
|
943
|
+
if (inLanguage.length > 0) {
|
|
944
|
+
ld.inLanguage = inLanguage.length === 1 ? inLanguage[0] : inLanguage;
|
|
952
945
|
}
|
|
953
|
-
|
|
946
|
+
|
|
947
|
+
if (currentType === 'NewsArticle') {
|
|
948
|
+
ld.headline = name && name.length > 110 ? name.substring(0, 110) : name;
|
|
949
|
+
ld.datePublished = time || new Date().toISOString();
|
|
950
|
+
ld.mainEntityOfPage = {
|
|
951
|
+
'@type': 'WebPage',
|
|
952
|
+
'@id': url
|
|
953
|
+
};
|
|
954
|
+
} else {
|
|
955
|
+
ld.operatingSystem = 'Web Browser';
|
|
956
|
+
ld.applicationCategory = applicationCategory || 'BrowserGame';
|
|
957
|
+
ld.offers = {
|
|
958
|
+
'@type': 'Offer',
|
|
959
|
+
'price': '0',
|
|
960
|
+
'priceCurrency': 'USD',
|
|
961
|
+
'availability': 'https://schema.org/InStock',
|
|
962
|
+
'url': url
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
if (aggregateRating && typeof aggregateRating === 'object' && Object.keys(aggregateRating).length > 0) {
|
|
966
|
+
ld.aggregateRating = aggregateRating;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
954
970
|
if (genre) {
|
|
955
971
|
ld.genre = genre;
|
|
956
972
|
}
|
|
973
|
+
|
|
957
974
|
return ld;
|
|
958
975
|
}
|
|
959
976
|
|
|
@@ -963,7 +980,7 @@ class wgtNodeUtils {
|
|
|
963
980
|
* @param {Array} languageList - 语言列表
|
|
964
981
|
* @param {string} url - 页面URL
|
|
965
982
|
*/
|
|
966
|
-
renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
|
|
983
|
+
renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
|
|
967
984
|
const languageLinkList = languageList.map(item => ({
|
|
968
985
|
rel: 'alternate',
|
|
969
986
|
hrefLang: item.code === 'en' ? 'en' : item.code,
|