hexo-related-popular-posts
Version:
A hexo plugin that generates a list of links to related posts and popular posts. Also , this plugin can get Visitor Counts (PageView) on posts.
33 lines (26 loc) • 1.1 kB
JavaScript
const hasha = require('hasha')
const fs = require('fs')
const pathFn = require('path')
// simple update checker
module.exports.chkUpdate = (config) => {
if (!config.popularPosts) return '0'
let settingsStr = JSON.stringify(config.popularPosts)
let shash = hasha(settingsStr, {algorithm: 'md5'} )
return shash
}
// morphologicalAnalysis's negativeKeywordsList update checker
module.exports.chkUpdate_ngw = (config) => {
if (!config.popularPosts || !config.popularPosts.morphologicalAnalysis || !config.popularPosts.morphologicalAnalysis.negativeKeywordsList) return '0'
let negativeWordStr = '0'
let nwPath = pathFn.join( process.env.PWD || process.cwd(), config.popularPosts.morphologicalAnalysis.negativeKeywordsList )
if (fs.existsSync( nwPath )) {
negativeWordStr = fs.readFileSync( nwPath, 'utf-8')
}
let shash = hasha(negativeWordStr, {algorithm: 'md5'} )
return shash
}
module.exports.getMD5 = (inStr) => {
if (!inStr || inStr == '') return ''
let shash = hasha(inStr, {algorithm: 'md5'} )
return shash
}