Skip to content

Commit

Permalink
Add option to show all posts on home page
Browse files Browse the repository at this point in the history
  • Loading branch information
probberechts committed Apr 11, 2017
1 parent 5869d06 commit bfec20d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ Setup the navigation menu in the theme's `_config.yml`:
LINK_NAME: URL
```
### Blog posts list on home page
You have two options for the list of blog posts on the home page:
- Show only the 5 most recent posts (default)
```
customize:
show_all_posts: false
post_count: 5
```
- Show all posts
```
customize:
show_all_posts: true
```
### Projects list
Create a projects file `source/_data/projects.json`.
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ customize:
twitter: /
facebook: /
linkedin: /
show_all_posts: false
post_count: 5
highlight: rainbow

Expand Down
10 changes: 9 additions & 1 deletion layout/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
<section id="writing">
<span class="h1"><a href="<%- url_for("archives") %>">Writing</a></span>
<ul class="post-list">
<% site.posts.sort('date', 'desc').limit(theme.customize.post_count || 5).each(function(post, i){ %>
<% if (theme.customize.show_all_posts) { %>
<% var show_posts = page.posts.sort('date', 'desc') %>
<% } else { %>
<% var show_posts = site.posts.sort('date', 'desc').limit(theme.customize.post_count || 5) %>
<% } %>
<% show_posts.each(function(post, i){ %>
<li class="post-item">
<%- partial('_partial/post/date', { post: post, class_name: 'meta' }) %>
<span><%- partial('_partial/post/title', { post: post, index: true, class_name: '' }) %></span>
</li>
<% }); %>
</ul>
<% if (theme.customize.show_all_posts) { %>
<%- partial('_partial/pagination') %>
<% } %>
</section>

<% if (site.data.projects) { %>
Expand Down

0 comments on commit bfec20d

Please sign in to comment.