wgt-node-utils 1.2.66 → 1.2.68
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 +46 -48
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -879,9 +879,9 @@ class wgtNodeUtils {
|
|
|
879
879
|
* @param {string} applicationCategory: 应用分类 BrowserGame BrowserNews
|
|
880
880
|
* @param {string} genre: 游戏所属分类
|
|
881
881
|
*/
|
|
882
|
-
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 }) => {
|
|
883
883
|
const pathWithoutLang = url ? url.replace(/(https?:\/\/[^/]+)\/en\b/, "$1") : '/';
|
|
884
|
-
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 });
|
|
885
885
|
const seoRenderAlternateLink = this.renderAlternateLink({ languageList, url, pathWithoutLang });
|
|
886
886
|
const seoraphAndTwitterFun = this.graphAndTwitterFun({ image, url, title, hostname, description, lang, pathWithoutLang });
|
|
887
887
|
const seoContent = {
|
|
@@ -911,63 +911,61 @@ class wgtNodeUtils {
|
|
|
911
911
|
* @param applicationCategory: 应用分类 BrowserGame BrowserNews
|
|
912
912
|
* @param genre: 游戏所属分类
|
|
913
913
|
*/
|
|
914
|
-
renderLdJson = ({ url, name, image, author, aggregateRating, description, hostname, type, languageList, applicationCategory, genre }) => {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
if (languageList) {
|
|
920
|
-
inLanguage = languageList.map(item => {
|
|
921
|
-
return item.code;
|
|
922
|
-
});
|
|
923
|
-
}
|
|
914
|
+
renderLdJson = ({ url, name, image, author, aggregateRating, description, hostname, type, languageList, applicationCategory, genre, time }) => {
|
|
915
|
+
const currentType = type || 'WebApplication';
|
|
916
|
+
const inLanguage = languageList ? languageList.map(item => item.code) : [];
|
|
917
|
+
const organizationUrl = `https://${hostname}`;
|
|
918
|
+
|
|
924
919
|
const ld = {
|
|
925
|
-
'@context': 'https://schema.org/',
|
|
926
|
-
'@type':
|
|
927
|
-
'name': name,
|
|
928
|
-
'author': {
|
|
929
|
-
'@type': 'Organization',
|
|
930
|
-
'name': author
|
|
931
|
-
},
|
|
932
|
-
'image': image,
|
|
920
|
+
'@context': 'https://schema.org/',
|
|
921
|
+
'@type': currentType,
|
|
922
|
+
'name': name,
|
|
933
923
|
'description': description,
|
|
934
|
-
'potentialAction': {
|
|
935
|
-
'@type': 'SearchAction',
|
|
936
|
-
'target': `https://${hostname}/search/{search_term_string}`,
|
|
937
|
-
'query-input': 'required name=search_term_string'
|
|
938
|
-
},
|
|
939
|
-
'inLanguage': inLanguage,
|
|
940
924
|
'url': url,
|
|
941
|
-
'
|
|
942
|
-
'
|
|
943
|
-
|
|
944
|
-
'
|
|
945
|
-
'
|
|
946
|
-
'priceCurrency': 'USD'
|
|
925
|
+
'image': image,
|
|
926
|
+
'publisher': {
|
|
927
|
+
'@type': 'Organization',
|
|
928
|
+
'name': author,
|
|
929
|
+
'url': organizationUrl
|
|
947
930
|
},
|
|
948
|
-
|
|
949
|
-
featureList: [
|
|
950
|
-
'No download required',
|
|
951
|
-
'Instant use in browser',
|
|
952
|
-
'Thousands of free content',
|
|
953
|
-
'Daily updates',
|
|
954
|
-
'Mobile compatible'
|
|
955
|
-
],
|
|
956
|
-
isAccessibleForFree: true,
|
|
957
|
-
"publisher": {
|
|
931
|
+
'author': {
|
|
958
932
|
'@type': 'Organization',
|
|
959
933
|
'name': author,
|
|
960
|
-
'url':
|
|
934
|
+
'url': organizationUrl
|
|
961
935
|
}
|
|
962
936
|
};
|
|
963
|
-
|
|
964
|
-
if (
|
|
965
|
-
ld.
|
|
937
|
+
|
|
938
|
+
if (inLanguage.length > 0) {
|
|
939
|
+
ld.inLanguage = inLanguage.length === 1 ? inLanguage[0] : inLanguage;
|
|
966
940
|
}
|
|
967
|
-
|
|
941
|
+
|
|
942
|
+
if (currentType === 'NewsArticle') {
|
|
943
|
+
ld.headline = name && name.length > 110 ? name.substring(0, 110) : name;
|
|
944
|
+
ld.datePublished = time || new Date().toISOString();
|
|
945
|
+
ld.mainEntityOfPage = {
|
|
946
|
+
'@type': 'WebPage',
|
|
947
|
+
'@id': url
|
|
948
|
+
};
|
|
949
|
+
} else {
|
|
950
|
+
ld.operatingSystem = 'Web Browser';
|
|
951
|
+
ld.applicationCategory = applicationCategory || 'BrowserGame';
|
|
952
|
+
ld.offers = {
|
|
953
|
+
'@type': 'Offer',
|
|
954
|
+
'price': '0',
|
|
955
|
+
'priceCurrency': 'USD',
|
|
956
|
+
'availability': 'https://schema.org/InStock',
|
|
957
|
+
'url': url
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
if (aggregateRating && typeof aggregateRating === 'object' && Object.keys(aggregateRating).length > 0) {
|
|
961
|
+
ld.aggregateRating = aggregateRating;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
|
|
968
965
|
if (genre) {
|
|
969
966
|
ld.genre = genre;
|
|
970
967
|
}
|
|
968
|
+
|
|
971
969
|
return ld;
|
|
972
970
|
}
|
|
973
971
|
|
|
@@ -977,7 +975,7 @@ class wgtNodeUtils {
|
|
|
977
975
|
* @param {Array} languageList - 语言列表
|
|
978
976
|
* @param {string} url - 页面URL
|
|
979
977
|
*/
|
|
980
|
-
renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
|
|
978
|
+
renderAlternateLink = ({ languageList, url, pathWithoutLang }) => {
|
|
981
979
|
const languageLinkList = languageList.map(item => ({
|
|
982
980
|
rel: 'alternate',
|
|
983
981
|
hrefLang: item.code === 'en' ? 'en' : item.code,
|