wgt-node-utils 1.2.62 → 1.2.64
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 +37 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -860,10 +860,14 @@ class wgtNodeUtils {
|
|
|
860
860
|
* @param {Array} languageList - 语言列表
|
|
861
861
|
* @param {string} lang - 语言代码
|
|
862
862
|
* @param {string} title - 页面标题
|
|
863
|
+
* @param {string} type: 页面类型
|
|
864
|
+
* @param {Array} languageCodeList: 语言代码列表
|
|
865
|
+
* @param {string} applicationCategory: 应用分类 BrowserGame BrowserNews
|
|
866
|
+
* @param {string} genre: 游戏所属分类
|
|
863
867
|
*/
|
|
864
|
-
seoFun = ({ url, name, image, author, aggregateRating, description, hostname, languageList, lang, title }) => {
|
|
868
|
+
seoFun = ({ url, name, image, author, aggregateRating, description, hostname, languageList, lang, title, type, applicationCategory, genre }) => {
|
|
865
869
|
const pathWithoutLang = url ? url.replace(/(https?:\/\/[^/]+)\/en\b/, "$1") : '/';
|
|
866
|
-
const seoRenderLdJson = this.renderLdJson({ pathWithoutLang, name, image, author, aggregateRating, description, hostname });
|
|
870
|
+
const seoRenderLdJson = this.renderLdJson({ pathWithoutLang, name, image, author, aggregateRating, description, hostname, type,languageList, applicationCategory, genre });
|
|
867
871
|
const seoRenderAlternateLink = this.renderAlternateLink({ languageList, url, pathWithoutLang });
|
|
868
872
|
const seoraphAndTwitterFun = this.graphAndTwitterFun({ image, url, title, hostname, description, lang, pathWithoutLang });
|
|
869
873
|
const seoContent = {
|
|
@@ -888,11 +892,24 @@ class wgtNodeUtils {
|
|
|
888
892
|
}
|
|
889
893
|
* @param description: 页面描述
|
|
890
894
|
* @param hostname: 网站域名
|
|
895
|
+
* @param type: 页面类型 ['VideoGame', 'WebApplication'] NewsArticle
|
|
896
|
+
* @param languageCodeList: 语言代码列表
|
|
897
|
+
* @param applicationCategory: 应用分类 BrowserGame BrowserNews
|
|
898
|
+
* @param genre: 游戏所属分类
|
|
891
899
|
*/
|
|
892
|
-
renderLdJson = ({ url, name, image, author, aggregateRating, description, hostname }) => {
|
|
900
|
+
renderLdJson = ({ url, name, image, author, aggregateRating, description, hostname, type, languageList, applicationCategory, genre }) => {
|
|
901
|
+
if (!type) {
|
|
902
|
+
type = 'WebApplication';
|
|
903
|
+
}
|
|
904
|
+
let inLanguage = [];
|
|
905
|
+
if (languageList) {
|
|
906
|
+
inLanguage = languageList.map(item => {
|
|
907
|
+
return item.code;
|
|
908
|
+
});
|
|
909
|
+
}
|
|
893
910
|
const ld = {
|
|
894
911
|
'@context': 'https://schema.org/', // 语境
|
|
895
|
-
'@type':
|
|
912
|
+
'@type': type,
|
|
896
913
|
'name': name, // 网站名称
|
|
897
914
|
'author': {
|
|
898
915
|
'@type': 'Organization',
|
|
@@ -905,14 +922,24 @@ class wgtNodeUtils {
|
|
|
905
922
|
'target': `https://${hostname}/search/{search_term_string}`,
|
|
906
923
|
'query-input': 'required name=search_term_string'
|
|
907
924
|
},
|
|
925
|
+
'inLanguage': inLanguage,
|
|
908
926
|
'url': url,
|
|
909
927
|
'operatingSystem': 'Web Browser',
|
|
910
|
-
'applicationCategory': 'BrowserGame',
|
|
928
|
+
'applicationCategory': applicationCategory || 'BrowserGame',
|
|
911
929
|
'offers': {
|
|
912
930
|
'@type': 'Offer',
|
|
913
931
|
'price': '0',
|
|
914
932
|
'priceCurrency': 'USD'
|
|
915
933
|
},
|
|
934
|
+
availableOnDevice: ["Mobile", "Tablet", "Desktop"],
|
|
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,
|
|
916
943
|
"publisher": {
|
|
917
944
|
'@type': 'Organization',
|
|
918
945
|
'name': author,
|
|
@@ -923,6 +950,10 @@ class wgtNodeUtils {
|
|
|
923
950
|
if (aggregateRating) {
|
|
924
951
|
ld.aggregateRating = aggregateRating;
|
|
925
952
|
}
|
|
953
|
+
// 仅部分页面拥有: 游戏所属分类
|
|
954
|
+
if (genre) {
|
|
955
|
+
ld.genre = genre;
|
|
956
|
+
}
|
|
926
957
|
return ld;
|
|
927
958
|
}
|
|
928
959
|
|
|
@@ -939,6 +970,7 @@ class wgtNodeUtils {
|
|
|
939
970
|
href: item.code === 'en' ? pathWithoutLang : url
|
|
940
971
|
}));
|
|
941
972
|
languageLinkList.push({ rel: 'alternate', hrefLang: 'x-default', href: pathWithoutLang });
|
|
973
|
+
languageLinkList.push({ rel: 'canonical', href: pathWithoutLang });
|
|
942
974
|
return languageLinkList
|
|
943
975
|
}
|
|
944
976
|
// Open Graph 和 Twitter Card 站外引流触点
|