Fix site to categorize and show categories automatically.
This commit is contained in:
parent
0820479a9e
commit
a86f57ec7f
|
@ -6,7 +6,7 @@
|
||||||
# 'jekyll serve'. If you change this file, please restart the server process.
|
# 'jekyll serve'. If you change this file, please restart the server process.
|
||||||
|
|
||||||
# Site settings
|
# Site settings
|
||||||
title: annabunches
|
title: Anna and the Bunches
|
||||||
email: annabunches@gmail.com
|
email: annabunches@gmail.com
|
||||||
description: > # this means to ignore newlines until "baseurl:"
|
description: > # this means to ignore newlines until "baseurl:"
|
||||||
The story of Anna and her lifelong friends, Left Bunch and Right Bunch.
|
The story of Anna and her lifelong friends, Left Bunch and Right Bunch.
|
||||||
|
|
13
_includes/category_list.html
Normal file
13
_includes/category_list.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<h1 class="page-heading">{{ include.category | capitalize }}</h1>
|
||||||
|
|
||||||
|
<ul class="post-list">
|
||||||
|
{% for post in site.categories[include.category] limit:5 %}
|
||||||
|
<li>
|
||||||
|
<span class="post-meta">{{ post.date | date: "%Y-%m-%d" }}</span>
|
||||||
|
<h2>
|
||||||
|
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
|
||||||
|
</h2>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<footer class="site-footer">
|
<footer class="site-footer">
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
||||||
<h2 class="footer-heading">{{ site.title }}</h2>
|
|
||||||
|
|
||||||
<div class="footer-col-wrapper">
|
<div class="footer-col-wrapper">
|
||||||
<div class="footer-col footer-col-1">
|
<div class="footer-col footer-col-1">
|
||||||
<ul class="contact-list">
|
<ul class="contact-list">
|
||||||
|
|
9
_plugins/auto_categories.rb
Normal file
9
_plugins/auto_categories.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Very simple plugin that adds a subdirectory under _posts as a category
|
||||||
|
|
||||||
|
def get_category_from_subdir(path)
|
||||||
|
path.sub(/^.*_posts\/(.*?)\/.*$/, "\\1")
|
||||||
|
end
|
||||||
|
|
||||||
|
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
|
||||||
|
post.data['categories'] << get_category_from_subdir(post.path)
|
||||||
|
end
|
22
index.html
22
index.html
|
@ -1,25 +1,15 @@
|
||||||
---
|
---
|
||||||
layout: default
|
layout: default
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class="home">
|
<div class="home">
|
||||||
{% for category in site.categories %}
|
{% for category in site.categories %}
|
||||||
<h1 class="page-heading">{{ category }}</h1>
|
{% if category.first == "meta" %} {% continue %} {% endif %}
|
||||||
|
<div class="column">
|
||||||
<ul class="post-list">
|
{% include category_list.html category=category.first %}
|
||||||
{% for post in site.categories.{{category}} %}
|
</div>
|
||||||
<li>
|
|
||||||
<span class="post-meta">{{ post.date | date: "%Y-%m-%d" }}</span>
|
|
||||||
|
|
||||||
<h2>
|
|
||||||
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
|
|
||||||
</h2>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | prepend: site.baseurl }}">via RSS</a></p>
|
<div class="site-updates">
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user