Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexo-related-popular-posts

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-related-popular-posts - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

lib/googleAnalytics.js

146

index.js

@@ -6,3 +6,2 @@ 'use strict';

var assign = require('object-assign');
var gaAnalytics = require('ga-analytics');
var moment = require('moment');

@@ -15,3 +14,2 @@ var util = require('./lib/util.js');

var isGARefresh = false;
var dateRangeArr = null;

@@ -34,2 +32,3 @@ var gaData = null;

var cache_exexpires = 10;
var pvMeasurementsStartDate = "";
var weight_of_tag_relevancy = 1.0;

@@ -43,3 +42,3 @@ var weight_of_contents_relevancy = 1.0;

if( hexo.config.popularPosts.googleAnalyticsAPI){
if( hexo.config.popularPosts.googleAnalyticsAPI ){
// Deprecated message

@@ -71,2 +70,13 @@ if( hexo.config.popularPosts.googleAnalyticsAPI.cache && ( hexo.config.popularPosts.googleAnalyticsAPI.cache.path != undefined || hexo.config.popularPosts.googleAnalyticsAPI.cache.expiresDate != undefined ) ){

}
if( hexo.config.popularPosts.googleAnalyticsAPI.pvMeasurementsStartDate != undefined){
var pvmstd = String(hexo.config.popularPosts.googleAnalyticsAPI.pvMeasurementsStartDate);
pvmstd = dr.getDateStrFromDate( new Date(pvmstd) );
if(pvmstd.match(/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/)){
pvMeasurementsStartDate = pvmstd;
}else{
lg.log("error", "Please check the 'pvMeasurementsStartDate' option. This option should be written in the form 'YYYY-MM-DD' ." , "_config.yml" , true);
return;
}
}

@@ -108,16 +118,18 @@ if( hexo.config.popularPosts.googleAnalyticsAPI.expiresDate != undefined){

"isNgwUpdate" : true ,
"isGaUpdate" : true ,
"settingsUpdate" : shash ,
"version" : pjson.version,
"dateRange" : dateRange,
"id" : id,
"email" : email,
"key" : key,
"viewId" : viewId,
"cache_path" : cache_path,
"cache_exexpires" : cache_exexpires,
"version" : pjson.version ,
"dateRange" : dateRange ,
"id" : id ,
"email" : email ,
"key" : key ,
"viewId" : viewId ,
"cache_path" : cache_path ,
"cache_exexpires" : cache_exexpires ,
"pvMeasurementsStartDate" : pvMeasurementsStartDate ,
"old_cacheDate" : "" ,
"weight_of_tag_relevancy" : weight_of_tag_relevancy,
"weight_of_contents_relevancy": weight_of_contents_relevancy,
"startDate" : dateRangeArr[0],
"endDate" : dateRangeArr[1],
"weight_of_tag_relevancy" : weight_of_tag_relevancy ,
"weight_of_contents_relevancy": weight_of_contents_relevancy ,
"startDate" : dateRangeArr[0] ,
"endDate" : dateRangeArr[1] ,
"gaData" : [] ,

@@ -131,17 +143,3 @@ "postPath" : []

// orverride config.popularPosts.tmp data
function orverrideTmp(inGaData){
hexo.config.popularPosts.tmp = assign( {},
hexo.config.popularPosts.tmp , {
"gaData" : inGaData
}
);
// console.log("-- (debug) hexo.config.popularPosts.tmp.gaData ---");
// for(var i=0; i<hexo.config.popularPosts.tmp.gaData.length; i++){
// console.log("tmp : " + hexo.config.popularPosts.tmp.gaData[i].path);
// }
}
// load cache data

@@ -160,3 +158,3 @@ if(cache_path && fs.existsSync(cache_path)){

if(gaData[0].cachedDate && (ndt - gaData[0].cachedDate) < cache_exexpires*24*60*60*1000 ){
isGARefresh = true;
hexo.config.popularPosts.tmp.isGaUpdate = false;
}

@@ -169,92 +167,11 @@ hexo.config.popularPosts.tmp.old_cacheDate = gaData[0].cachedDate;

if(gaData){
orverrideTmp(gaData[0].gaData);
util.orverrideTmp(gaData[0].gaData , hexo);
}else{
orverrideTmp([]);
util.orverrideTmp([] , hexo);
}
}
// load google analytics data
if(!isGARefresh){
if(id && email && key && viewId){
gaAnalytics({
dimensions : 'ga:pagePath' ,
metrics : 'ga:pageviews' ,
clientId : id ,
serviceEmail: email ,
key : key ,
ids : viewId ,
startDate : dateRangeArr[0] ,
endDate : dateRangeArr[1] ,
sort : '-ga:pageviews'
}, function (err, res) {
if (err) {
lg.log("error", "(ga-analytics error) " + err + "\nPlease check the googleAnalyticsAPI options or environment variables." , "_config.yml" , true );
return;
} else {
gaData = [{ "cachedDate":ndt , "gaData":[] }];
if( res.rows && res.rows.length > 0){
for( var i = 0; i < res.rows.length; i++){
var isAleadyCreated = false;
for(var k = 0; k < hexo.config.popularPosts.tmp.gaData.length; k++){
if( hexo.config.popularPosts.tmp.gaData[k].path == util.normalizeURL(res.rows[i][0]) ){
gaData[0].gaData.push( util.gaDataModel({
"updated" : hexo.config.popularPosts.tmp.gaData[k].updated || "0" ,
"title" : hexo.config.popularPosts.tmp.gaData[k].title || "" ,
"path" : res.rows[i][0] ,
"eyeCatchImage" : hexo.config.popularPosts.tmp.gaData[k].eyeCatchImage || "" ,
"excerpt" : hexo.config.popularPosts.tmp.gaData[k].excerpt || "" ,
"date" : hexo.config.popularPosts.tmp.gaData[k].date || "",
"pv" : Number(res.rows[i][1]) ,
"post.categories": hexo.config.popularPosts.tmp.gaData[k].post.categories || [] ,
"internalLinks" : hexo.config.popularPosts.tmp.gaData[k].internalLinks || [] ,
"keywords" : hexo.config.popularPosts.tmp.gaData[k].keywords || [] ,
"keywordsLength" : hexo.config.popularPosts.tmp.gaData[k].keywordsLength || 0
}) );
isAleadyCreated = true;
break;
}
}
if(!isAleadyCreated){
gaData[0].gaData.push( util.gaDataModel({
"path": res.rows[i][0] ,
"pv" : Number( res.rows[i][1] )
}) );
}
}
}
// Adding a page without access.
for(var k = 0; k < hexo.config.popularPosts.tmp.gaData.length; k++){
var isNotMatch = true;
if( res.rows && res.rows.length > 0 ){
for( var i = 0; i < res.rows.length; i++){
if( hexo.config.popularPosts.tmp.gaData[k].path == util.normalizeURL(res.rows[i][0]) ){
isNotMatch = false;
}
}
}
if(isNotMatch){
gaData[0].gaData.push( hexo.config.popularPosts.tmp.gaData[k] );
}
}
// normalized URL
var gaData_temp = util.normalizeGaData( gaData[0].gaData );
gaData[0].gaData = null;
gaData[0].gaData = gaData_temp;
lg.log("info", "Google Analytics Page View Data was refreshed." , null , false);
orverrideTmp(gaData[0].gaData);
}
});
}
}
hexo.extend.filter.register('after_init', require('./lib/googleAnalytics'), {async: true});
hexo.extend.filter.register('after_post_render', require('./lib/collector'), {async: true});

@@ -264,2 +181,3 @@ hexo.extend.filter.register('after_generate', require('./lib/cache') );

hexo.extend.helper.register('popular_posts_json', require('./lib/helper-json'));
hexo.extend.helper.register('popular_posts_pv', require('./lib/pv'));

@@ -12,2 +12,13 @@

module.exports.getDateStrFromDate = function(inDate){
if(!inDate)return "0000-00-00";
return getDateStr(inDate.getTime());
};
module.exports.getYesterdayDateStr = function(){
var nDate = new Date();
var yDateMSec = nDate.getTime() - 24*60*60*1000;
return getDateStr(yDateMSec);
};
function getDateStr(inUnixDateTime){

@@ -14,0 +25,0 @@ var d = new Date(inUnixDateTime);

@@ -14,2 +14,3 @@ 'use strict';

var popularCnt = 0;
var postsCat = "";
var weight_of_tag_relevancy;

@@ -29,8 +30,9 @@ var weight_of_contents_relevancy;

options = assign({
maxCount : 5,
ulClass : 'popular-posts',
PPMixingRate: 0.0,
isDate : false,
isImage : false,
isExcerpt : false
maxCount : 5,
ulClass : 'popular-posts',
PPMixingRate : 0.0,
isDate : false,
isImage : false,
isExcerpt : false,
PPCategoryFilter: "" ,
}, options);

@@ -46,2 +48,6 @@

if(options.PPCategoryFilter && options.PPCategoryFilter != ""){
postsCat = options.PPCategoryFilter;
}
weight_of_tag_relevancy = _this.config.popularPosts.tmp.weight_of_tag_relevancy;

@@ -57,7 +63,9 @@ weight_of_contents_relevancy = _this.config.popularPosts.tmp.weight_of_contents_relevancy;

var isOrverlapping;
var postsCat = "";
for(i = 0; i < _this.config.popularPosts.tmp.gaData.length; i++){
if(_this.config.popularPosts.tmp.gaData[i].path == _this.post.path){
postsCat = _this.config.popularPosts.tmp.gaData[i].categories;
if(_this.post != undefined && postsCat == ""){
for(i = 0; i < _this.config.popularPosts.tmp.gaData.length; i++){
if(_this.config.popularPosts.tmp.gaData[i].path == _this.post.path){
postsCat = _this.config.popularPosts.tmp.gaData[i].categories;
break;
}
}

@@ -68,3 +76,3 @@ }

if(_this.config.popularPosts.tmp.gaData[i].date != ""){
if(_this.config.popularPosts.tmp.gaData[i].categories == postsCat)gaData_opt.push(_this.config.popularPosts.tmp.gaData[i]);
if(postsCat == "" || _this.config.popularPosts.tmp.gaData[i].categories == postsCat)gaData_opt.push(_this.config.popularPosts.tmp.gaData[i]);
}

@@ -90,64 +98,63 @@ }

//-------------------------------------------
// Related posts (tag)
//-------------------------------------------
if(_this.post.tags && _this.post.tags.length > 0){
_this.post.tags.each(function(tag){
tag.posts.each(function(post){
var description = null;
var eyeCatchImage = null;
// get description
if(post.description && post.description != ""){
description = post.description;
}else if(post.excerpt && post.excerpt != ""){
description = post.excerpt;
}
// get eyecatch image
if(post.eyeCatchImage){
eyeCatchImage = post.eyeCatchImage;
}else{
var imgMatch = post.content.match(/\ssrc\=\"(.+?[\.jpg|\.jpeg|\.png|\.gif])\"/);
if(imgMatch && imgMatch.length > 2)eyeCatchImage = imgMatch[1];
}
if(post.published){
var isExistPost = false;
for( i = 0; i < relatedPosts.length; i++){
if(relatedPosts[i].path == post.path){
relatedPosts[i].relatedDegree++;
isExistPost = true;
break;
if( Number(options.PPMixingRate) != 1.0 ){
//-------------------------------------------
// Related posts (tag)
//-------------------------------------------
if(_this.post.tags && _this.post.tags.length > 0){
_this.post.tags.each(function(tag){
tag.posts.each(function(post){
var description = null;
var eyeCatchImage = null;
// get description
if(post.description && post.description != ""){
description = post.description;
}else if(post.excerpt && post.excerpt != ""){
description = post.excerpt;
}
// get eyecatch image
if(post.eyeCatchImage){
eyeCatchImage = post.eyeCatchImage;
}else{
var imgMatch = post.content.match(/\ssrc\=\"(.+?[\.jpg|\.jpeg|\.png|\.gif])\"/);
if(imgMatch && imgMatch.length > 2)eyeCatchImage = imgMatch[1];
}
if(post.published){
var isExistPost = false;
for( i = 0; i < relatedPosts.length; i++){
if(relatedPosts[i].path == post.path){
relatedPosts[i].relatedDegree++;
isExistPost = true;
break;
}
}
}
if(!isExistPost && _this.post.path != post.path){
var pv = 0;
if(popularPosts.length > 0){
for( m = 0; m < popularPosts.length; m++){
if(popularPosts[m].path == post.path){
pv = popularPosts[m].pv;
break;
if(!isExistPost && _this.post.path != post.path){
var pv = 0;
if(popularPosts.length > 0){
for( m = 0; m < popularPosts.length; m++){
if(popularPosts[m].path == post.path){
pv = popularPosts[m].pv;
break;
}
}
}
relatedPosts.push({
"title" : post.title ,
"path" : post.path ,
"eyeCatchImage" : eyeCatchImage ,
"excerpt" : description ,
"date" : post.date ,
"pv" : pv ,
"relatedDegree" : 1 ,
"relatedDegree_ma": 0 ,
"matchKeyWord" : matchKeyWord
});
}
relatedPosts.push({
"title" : post.title ,
"path" : post.path ,
"eyeCatchImage" : eyeCatchImage ,
"excerpt" : description ,
"date" : post.date ,
"pv" : pv ,
"relatedDegree" : 1 ,
"relatedDegree_ma": 0 ,
"matchKeyWord" : matchKeyWord
});
}
}
});
});
});
}
}

@@ -160,86 +167,86 @@

//-------------------------------------------
// Related posts ( Contents morphological analysis )
//-------------------------------------------
if(_this.config.popularPosts.morphologicalAnalysis && _this.config.popularPosts.tmp.gaData){
var postsGaData;
for( i = 0; i < _this.config.popularPosts.tmp.gaData.length; i++){
if(_this.config.popularPosts.tmp.gaData[i].path == _this.post.path){
postsGaData = _this.config.popularPosts.tmp.gaData[i];
break;
//-------------------------------------------
// Related posts ( Contents morphological analysis )
//-------------------------------------------
if(_this.config.popularPosts.morphologicalAnalysis && _this.config.popularPosts.tmp.gaData){
var postsGaData;
for( i = 0; i < _this.config.popularPosts.tmp.gaData.length; i++){
if(_this.config.popularPosts.tmp.gaData[i].path == _this.post.path){
postsGaData = _this.config.popularPosts.tmp.gaData[i];
break;
}
}
}
if(postsGaData){
for( i = 0; i < _this.config.popularPosts.tmp.gaData.length; i++){
var matchScore = 0;
var matchKeyWord = [];
if(_this.config.popularPosts.tmp.gaData[i].path != _this.post.path){
// Relevance of content's keywords
for(k = 0; k < postsGaData.keywords.length; k++){
for(n = 0; n < _this.config.popularPosts.tmp.gaData[i].keywords.length; n++){
if(postsGaData.keywords[k].w == _this.config.popularPosts.tmp.gaData[i].keywords[n].w && postsGaData.categories == _this.config.popularPosts.tmp.gaData[i].categories ){
matchScore += Number(postsGaData.keywords[k].f) / (Number(postsGaData.keywordsLength) || 500 ) + Number(_this.config.popularPosts.tmp.gaData[i].keywords[n].f) / (Number(_this.config.popularPosts.tmp.gaData[i].keywordsLength) || 500);
matchKeyWord.push({"w":_this.config.popularPosts.tmp.gaData[i].keywords[n].w , "f":_this.config.popularPosts.tmp.gaData[i].keywords[n].f});
if(postsGaData){
for( i = 0; i < _this.config.popularPosts.tmp.gaData.length; i++){
var matchScore = 0;
var matchKeyWord = [];
if(_this.config.popularPosts.tmp.gaData[i].path != _this.post.path){
// Relevance of content's keywords
for(k = 0; k < postsGaData.keywords.length; k++){
for(n = 0; n < _this.config.popularPosts.tmp.gaData[i].keywords.length; n++){
if(postsGaData.keywords[k].w == _this.config.popularPosts.tmp.gaData[i].keywords[n].w && postsGaData.categories == _this.config.popularPosts.tmp.gaData[i].categories ){
matchScore += Number(postsGaData.keywords[k].f) / (Number(postsGaData.keywordsLength) || 500 ) + Number(_this.config.popularPosts.tmp.gaData[i].keywords[n].f) / (Number(_this.config.popularPosts.tmp.gaData[i].keywordsLength) || 500);
matchKeyWord.push({"w":_this.config.popularPosts.tmp.gaData[i].keywords[n].w , "f":_this.config.popularPosts.tmp.gaData[i].keywords[n].f});
}
}
}
}
// Relevance of internal link
for(k = 0; k < postsGaData.internalLinks.length; k++){
if(pathFn.normalize(postsGaData.internalLinks[k]) == pathFn.normalize(_this.config.popularPosts.tmp.gaData[i].path)){
matchScore += 5.0;
// Relevance of internal link
for(k = 0; k < postsGaData.internalLinks.length; k++){
if(pathFn.normalize(postsGaData.internalLinks[k]) == pathFn.normalize(_this.config.popularPosts.tmp.gaData[i].path)){
matchScore += 5.0;
}
}
}
}
if(matchScore > 0){
var isAleadyCreatedList = false;
for( q = 0; q < relatedPosts.length; q++){
if(relatedPosts[q].path == _this.config.popularPosts.tmp.gaData[i].path){
relatedPosts[q].relatedDegree_ma = matchScore;
relatedPosts[q].matchKeyWord = matchKeyWord;
isAleadyCreatedList = true;
break;
if(matchScore > 0){
var isAleadyCreatedList = false;
for( q = 0; q < relatedPosts.length; q++){
if(relatedPosts[q].path == _this.config.popularPosts.tmp.gaData[i].path){
relatedPosts[q].relatedDegree_ma = matchScore;
relatedPosts[q].matchKeyWord = matchKeyWord;
isAleadyCreatedList = true;
break;
}
}
if( !isAleadyCreatedList ){
relatedPosts.push({
"title" : _this.config.popularPosts.tmp.gaData[i].title ,
"path" : _this.config.popularPosts.tmp.gaData[i].path ,
"eyeCatchImage" : _this.config.popularPosts.tmp.gaData[i].eyeCatchImage ,
"excerpt" : _this.config.popularPosts.tmp.gaData[i].excerpt ,
"date" : _this.config.popularPosts.tmp.gaData[i].date ,
"pv" : _this.config.popularPosts.tmp.gaData[i].pv ,
"relatedDegree" : 0 ,
"relatedDegree_ma": matchScore ,
"matchKeyWord" : matchKeyWord
});
}
}
if( !isAleadyCreatedList ){
relatedPosts.push({
"title" : _this.config.popularPosts.tmp.gaData[i].title ,
"path" : _this.config.popularPosts.tmp.gaData[i].path ,
"eyeCatchImage" : _this.config.popularPosts.tmp.gaData[i].eyeCatchImage ,
"excerpt" : _this.config.popularPosts.tmp.gaData[i].excerpt ,
"date" : _this.config.popularPosts.tmp.gaData[i].date ,
"pv" : _this.config.popularPosts.tmp.gaData[i].pv ,
"relatedDegree" : 0 ,
"relatedDegree_ma": matchScore ,
"matchKeyWord" : matchKeyWord
});
}
}
}
}
// sort by relatedDegree & pv
relatedPosts.sort(function (a,b){
var degreeA = a.relatedDegree * weight_of_tag_relevancy + a.relatedDegree_ma * weight_of_contents_relevancy;
var degreeB = b.relatedDegree * weight_of_tag_relevancy + b.relatedDegree_ma * weight_of_contents_relevancy;
if(degreeB == degreeA){
return (b.pv - a.pv);
}else{
return (degreeB - degreeA);
}
});
}
// sort by relatedDegree & pv
relatedPosts.sort(function (a,b){
var degreeA = a.relatedDegree * weight_of_tag_relevancy + a.relatedDegree_ma * weight_of_contents_relevancy;
var degreeB = b.relatedDegree * weight_of_tag_relevancy + b.relatedDegree_ma * weight_of_contents_relevancy;
if(degreeB == degreeA){
return (b.pv - a.pv);
}else{
return (degreeB - degreeA);
}
});
// //-------------------------------------------

@@ -246,0 +253,0 @@ // // (debug) Related posts

@@ -24,4 +24,5 @@ 'use strict';

// console.log( gaData[k].pv +" + "+ afterAddedData[i].pv + " -> " + afterAddedData[i].path);
gaData[k].pv = gaData[k].pv + afterAddedData[i].pv;
isAdded = true;
gaData[k].pv = gaData[k].pv + afterAddedData[i].pv;
gaData[k].totalPV = gaData[k].totalPV + afterAddedData[i].totalPV;
isAdded = true;
break;

@@ -110,2 +111,3 @@ }

"pv" : 0 ,
"totalPV" : 0 ,
"categories" : [] ,

@@ -140,2 +142,17 @@ "internalLinks" : [] ,

return catName;
}
}
// orverride config.popularPosts.tmp data
module.exports.orverrideTmp = function(inGaData , inHexo){
inHexo.config.popularPosts.tmp = assign( {},
inHexo.config.popularPosts.tmp , {
"gaData" : inGaData
}
);
// console.log("-- (debug) inHexo.config.popularPosts.tmp.gaData ---");
// for(var i=0; i<inHexo.config.popularPosts.tmp.gaData.length; i++){
// console.log("tmp : " + inHexo.config.popularPosts.tmp.gaData[i].path);
// }
}
{
"name": "hexo-related-popular-posts",
"version": "0.1.5",
"version": "0.1.6",
"main": "index",

@@ -16,3 +16,3 @@ "dependencies": {

},
"description": "A hexo plugin that generates a list of links to related posts and popular posts.",
"description": "A hexo plugin that generates a list of links to related posts and popular posts. Also , this plugin can get Visitor Counts (PV) on posts.",
"devDependencies": {

@@ -40,3 +40,6 @@ "hexo": "^3.0.0-rc.3"

"list",
"helper"
"helper",
"visitorCounts",
"pageViews",
"pv"
],

@@ -43,0 +46,0 @@ "license": "MIT",

# hexo-related-popular-posts
A hexo plugin that generates a list of links to related posts or popular posts.
A hexo plugin that generates a list of links to related posts or popular posts. Also , this plugin can get Visitor Counts (PV) on posts.
## Overview
- Generate related list of posts (Relevance of tags & Relevance of contents)
- Generate popular list of posts (Sort posts by page views)
- Generate related list of posts. (Relevance of tags & Relevance of contents)
- Generate popular list of posts. (Sort posts by page views)
- Get Page Views information on posts. (Visitor Counter)

@@ -28,3 +29,3 @@ A hexo plugin that generates a list of links to related posts based on tags , and plugin that generates a list of links to popular posts base on page view of Google Analytics. Popular posts is need Google Analytics API. Also , this plugin can generates a list of links to related posts based on contents.

First, add the following helper tag in template file for article. Please edit `themes/(your-theme)/layout/_partial/your_template.ejs`.
First, add the following `popular_posts()` helper tag in template file for article. Please edit `themes/(your-theme)/layout/_partial/your_template.ejs`.

@@ -59,2 +60,3 @@ ``` ejs

- [Customize HTML](https://github.com/tea3/hexo-related-popular-posts#customize-html)
- [Visitor Counter](https://github.com/tea3/hexo-related-popular-posts#visitor-counter)

@@ -64,3 +66,3 @@

```
``` yaml
# More detailed settings

@@ -77,2 +79,3 @@ popularPosts:

expiresDate: 10
pvMeasurementsStartDate: 2015/11/01
# cache: # (Deprecated) This options is Deprecated > v0.1.3

@@ -114,2 +117,3 @@ # path: hexo-related-popular-posts-ga-cached.json # (Deprecated) This options is Deprecated > v0.1.3

| isExcerpt| visible the excerpt | `false` |
| PPCategoryFilter | Option to fix category on Popular Posts | `undefined` |

@@ -223,3 +227,3 @@ ### Helper's Option Examples

This option improves the generation speed.
This option improves the generation speed. please set the `cache` option.

@@ -236,3 +240,3 @@ ``` yaml

When this option is enabled, logs are displayed.
When this option is enabled, logs are displayed. please set the `log` option.

@@ -304,2 +308,32 @@ ``` yaml

## Visitor Counter
This plugin can get Page Views information on posts. please set the `pvMeasurementsStartDate` option. Also , Visitor Counter is need [Google Analytics API](https://github.com/tea3/hexo-related-popular-posts#popular-posts) .
First , please edit your config file `_config.yml`.
``` yaml
popularPosts:
# (optional) Popular posts options
googleAnalyticsAPI:
clientId: ******.apps.googleusercontent.com
serviceEmail: *****@developer.gserviceaccount.com
key: /hexo-project-root/path/to/google-services.pem
viewId: 12345678
dateRange: 30
expiresDate: 10
pvMeasurementsStartDate: 2015/11/01
```
Second , add the following `popular_posts_pv()` helper tag in template file for article. please edit `themes/(your-theme)/layout/_partial/your_article_template.ejs` .
``` ejs
This post's Visitor Counts is
<%- popular_posts_pv() %>
views.
```
---
## License

@@ -306,0 +340,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc