hexo-related-popular-posts プラグイン
Created|Updated
https://github.com/tea3/hexo-related-popular-posts
hexo-related-popular-posts プラグインは関連記事や人気の記事一覧を生成するHexo のプラグインです。
freemind テーマで関連記事を表示してみました。
Google Analytics API で収集した情報で人気の記事も表示してみました。
環境
構築 - 関連記事
インストール
- hexo-related-popular-posts パッケージ
$ npm install hexo-related-popular-posts --save
|
ga-analytics の修正
./node_modules/ga-analytics/module.js88 89
| fs.writeFile(sessionFile, JSON.stringify(result), function(err) {});
|
./node_modules/ga-analytics/bin/ga-analytics50 51 52 53 54
| if(res === undefined) { } else if(program.json) { console.log(res); } else {
|
freemind テーマの設定
./themes/freemind/layout/_partial/article.ejs39 40 41 42 43
| <section id="related_posts"> <h2 class="title"><%= __('related_posts') %></h2> <%- popular_posts( {} , item ) %> </section>
|
./themes/freemind/languages/ja_JP.yml
./themes/freemind/source/css/style.css623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
| .popular-posts { padding: 0 !important; list-style: none !important; }
.popular-posts h3 { margin: 0 !important; color: #337ab7 !important; font-size: 1.0em !important; line-height: 1.5em; font-weight: normal; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.popular-posts h3:before{ content: "\f016"; font-family: FontAwesome; padding-right:0.3em; }
|
Hexo の設定
./_config.yml135 136 137
| popularPosts: morphologicalAnalysis:
|
構築 - 人気の記事
hexo-related-popular-posts の修正
./node_modules/hexo-related-popular-posts/lib/list-json.js167 168 169 170 171 172 173 174
| if ( Number(inOptions.PPMixingRate) != 1.0 ) { if (postData) { if (postData.tags && postData.tags.length > 0 && postData.tags.each) { postData.tags.each((tag) => {
|
./node_modules/hexo-related-popular-posts/lib/list-json.js115 116 117 118 119 120 121 122
| } else { for ( i = 0; i < config.popularPosts.tmp.gaData.length; i++) { if (config.popularPosts.tmp.gaData[i] != && config.popularPosts.tmp.gaData[i].date != && config.popularPosts.tmp.gaData[i].date != undefined && config.popularPosts.tmp.gaData[i].date != '') {
|
./node_modules/hexo-related-popular-posts/lib/googleAnalytics.js71 72 73 74 75 76 77
| let getPVfromGA = (inHexo) => { return new Promise( (resolve, reject) => { let gaData
if (1) {
|
freemind テーマの設定
./themes/freemind/layout/_widget/popular_posts.ejs1 2 3 4 5 6 7 8
| <% if (site.posts.length){ %> <div class="widget"> <h4><%= __('popular_posts') %></h4> <%- popular_posts({maxCount: 10 , ulClass: 'popular-posts' , PPMixingRate: 1.0 , isExcerpt: false}) %> </div> <% } %>
|
./themes/freemind/languages/ja_JP.yml
./themes/freemind/_config.yml104 105 106 107 108 109 110 111
| widgets: - search
- recent_posts - popular_posts - links
|
Hexo の設定
./_config.yml135 136 137 138 139 140 141 142 143
| popularPosts: morphologicalAnalysis: googleAnalyticsAPI: clientId: ******.apps.googleusercontent.com serviceEmail: *****@developer.gserviceaccount.com key: /hexo-project-root/path/to/google-services.pem viewId: 12345678 dateRange: 30 expiresDate: 10
|
実行
$ hexo clean $ hexo g $ hexo s
|
利用
記事にタグをつけます。