Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add recommeded posts #77

Merged
merged 1 commit into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ $ npm install hexo-tag-bootstrap --save
$ npm install hexo-generator-search --save
```

4) Create pages
4) install [hexo-recommended-posts](https://github.com/huiwang/hexo-recommended-posts) (*optional*):

``` sh
$ npm install hexo-recommended-posts --save
```

5) Create pages

Freemind offers you the customized Categories, Tags and About pages. But you need to manually create these page at your 'source' folder.

Expand Down Expand Up @@ -135,6 +141,11 @@ favicon: favicon.png
fancybox: true
duoshuo_shortname:

# Recommended posts
# Dependency: https://github.com/huiwang/hexo-recommended-posts
recommended_posts:
enabled: false

# analytics
google_analytics:
enable: false
Expand Down Expand Up @@ -169,6 +180,7 @@ comment_js:
* **rss** - RSS link
* **fancybox** - Enable [Fancybox](http://fancyapps.com/fancybox/)
* **duoshuo_shortname** - DuoShuo ID, if you prefer to use duoshuo instead of Disqus
* **recommended_posts** - Enable recommended posts
* **analytics** - Analytics ID. Supports both Google Analytics and Baidu Tongji.
* **swiftype_key** - Swifttype key to enable local searching. Leave it blank or comment this line if you want to use build-in local search engine.
* **bdshare** - Baidu share button at the bottom of article.
Expand Down
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ fancybox: true
favicon: favicon.png
duoshuo_shortname: #freemindtheme

# Recommended posts
# Dependency: https://github.com/huiwang/hexo-recommended-posts
recommended_posts:
enabled: false

# Analytics
google_analytics:
enable: false
Expand Down
1 change: 1 addition & 0 deletions languages/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ top: Pin
no_comment: "No comments yet. Press the button and go to comment now!"
go_to_comment: "Go to comment"
recent_comments: "Recent Comments"
recommended_posts: "Recommended Posts"
1 change: 1 addition & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ top: 置顶
no_comment: "暂时还没有留言呢,点击下面的按钮去留言吧!"
go_to_comment: "去留言"
recent_comments: "最新留言"
recommended_posts: "推荐文章"
5 changes: 5 additions & 0 deletions layout/_partial/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<%- item.content %>
</div>

<!-- recommended posts -->
<% if (post && theme.recommended_posts.enabled) { %>
<%- partial('post/recommended_posts', {page: item, site: site}) %>
<% } %>

<div>
<center>
<%- partial('post/pagination', {page: item}) %>
Expand Down
11 changes: 11 additions & 0 deletions layout/_partial/post/recommended_posts.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% var post_list = recommended_posts(page, site) %>
<% if(post_list.length > 0) { %>
<div class="recommended_posts">
<h1><%= __('recommended_posts') %></h1>
<ul>
<% post_list.forEach(function(link) { %>
<li><a href="<%= link.permalink %>"><%= link.title %></a></li>
<% }) %>
</ul>
</div>
<% } %>