).append($('').text('閱讀次數 ' + count)) ) } } var db = firebase.firestore() var articles = db.collection('articles') //https://hexo.io/zh-tw/docs/variables.html var isPost = ''.length > 0 var isArchive = '' === 'true' var isCategory = ''.length > 0 var isTag = ''.length > 0 if (isPost) { //is article page var title = '' var doc = articles.doc(title) getCount(doc, true).then(appendCountTo($('.post-meta'))) } else if (!isArchive && !isCategory && !isTag) { //is index page var titles = [] //array to titles var postsstr = 'titles.push("Hexo配置Google Analytics");titles.push("图片相对路径测试");titles.push("更改Hexo链接格式");titles.push("Hexo-Next-RSS设置");' //if you have a better way to get titles of posts, please change it eval(postsstr) var promises = titles.map(function (title) { return articles.doc(title) }).map(function (doc) { return getCount(doc) }) Promise.all(promises).then(function (counts) { var metas = $('.post-meta') counts.forEach(function (val, idx) { appendCountTo(metas[idx])(val) }) }) } })()