|
@@ -3948,51 +3948,8 @@ let tags = [
|
|
|
|
|
|
|
|
// tags.forEach(e => e.color = getRandomDarkColor());
|
|
// tags.forEach(e => e.color = getRandomDarkColor());
|
|
|
|
|
|
|
|
-// let tagSeoMap = {};
|
|
|
|
|
|
|
|
|
|
-// async function getTagSeoTitle(tag, lang) {
|
|
|
|
|
-// let item = tagSeoMap[tag];
|
|
|
|
|
-// if (!item) {
|
|
|
|
|
-// let doc = await models.TagSeo.findOne({ tag }).lean();
|
|
|
|
|
-// if (doc) {
|
|
|
|
|
-// try {
|
|
|
|
|
-// doc.seoTitle = JSON.parse(doc.seoTitle);
|
|
|
|
|
-// doc.seoDescription = JSON.parse(doc.seoDescription);
|
|
|
|
|
-// tagSeoMap[tag] = doc;
|
|
|
|
|
-// item = doc;
|
|
|
|
|
-// } catch (e) {
|
|
|
|
|
-// console.error(e.message);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// if (item) {
|
|
|
|
|
-// return tagSeoMap[tag].seoTitle[lang];
|
|
|
|
|
-// } else {
|
|
|
|
|
-// return `${tag} coloring pages | ${translate.printableColoringPage[lang]}`;
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
|
|
|
-// async function getTagSeoDescription(tag, lang) {
|
|
|
|
|
-// let item = tagSeoMap[tag];
|
|
|
|
|
-// if (!item) {
|
|
|
|
|
-// let doc = await models.TagSeo.findOne({ tag }).lean();
|
|
|
|
|
-// if (doc) {
|
|
|
|
|
-// try {
|
|
|
|
|
-// doc.seoTitle = JSON.parse(doc.seoTitle);
|
|
|
|
|
-// doc.seoDescription = JSON.parse(doc.seoDescription);
|
|
|
|
|
-// tagSeoMap[tag] = doc;
|
|
|
|
|
-// item = doc;
|
|
|
|
|
-// } catch (e) {
|
|
|
|
|
-// console.error(e.message);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// if (item) {
|
|
|
|
|
-// return tagSeoMap[tag].seoDescription[lang];
|
|
|
|
|
-// } else {
|
|
|
|
|
-// return meta.tagDescription[lang];
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
|
|
|
const tagsHashMap = tags.reduce((acc, obj) => {
|
|
const tagsHashMap = tags.reduce((acc, obj) => {
|
|
|
acc[obj.tag] = obj;
|
|
acc[obj.tag] = obj;
|
|
@@ -4000,6 +3957,39 @@ const tagsHashMap = tags.reduce((acc, obj) => {
|
|
|
}, {});
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+function getTagSeoTitle(tag, lang) {
|
|
|
|
|
+ let item = tagsHashMap[tag];
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ // return tagsHashMap[tag]['seoTitle'][lang];
|
|
|
|
|
+ return `${tagsHashMap[tag]['title'][lang]} ${translate.coloringPages[lang]} ${translate.freePrintablePaint[lang]}`; // 用统一的吧
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let uppercaseTag = tag.charAt(0).toUpperCase() + tag.slice(1);
|
|
|
|
|
+
|
|
|
|
|
+ return `${uppercaseTag} ${translate.coloringPages.en} ${translate.freePrintablePaint.en}`;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function getTagSeoDescription(tag, lang) {
|
|
|
|
|
+ let item = tagsHashMap[tag];
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ return tagsHashMap[tag]['seoDescription'][lang];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let uppercaseTag = tag.charAt(0).toUpperCase() + tag.slice(1);
|
|
|
|
|
+ return `${uppercaseTag} ${translate.coloringPages[lang]}, ${translate.commonDescription[lang]}`;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function getTagH1Title(tag, lang) {
|
|
|
|
|
+ let item = tagsHashMap[tag];
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ return `${tagsHashMap[tag]['title'][lang]} ${translate.coloringPages[lang]}`; // 用统一的吧
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let uppercaseTag = tag.charAt(0).toUpperCase() + tag.slice(1);
|
|
|
|
|
+ return `${uppercaseTag} ${translate.coloringPages.en}`;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// 刷新tag作品数量
|
|
// 刷新tag作品数量
|
|
|
async function refreshTagCount() {
|
|
async function refreshTagCount() {
|
|
|
let allTags = await models.Art.aggregate([
|
|
let allTags = await models.Art.aggregate([
|
|
@@ -4026,4 +4016,4 @@ async function refreshTagCount() {
|
|
|
|
|
|
|
|
refreshTagCount();
|
|
refreshTagCount();
|
|
|
|
|
|
|
|
-module.exports = { tags, tagsHashMap, refreshTagCount };
|
|
|
|
|
|
|
+module.exports = { tags, tagsHashMap, refreshTagCount, getTagSeoTitle, getTagSeoDescription, getTagH1Title };
|