Skip to content

Commit 22d90ed

Browse files
Add categories to posts
1 parent 1f7fdde commit 22d90ed

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ github_username: andrew-codechimp
1010
# Build settings
1111
theme: minima
1212

13+
permalink: /:title/
14+
1315
plugins:
1416
- jekyll-feed
1517
- jekyll-gist

_layouts/post.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
layout: default
3+
---
4+
<article class="post h-entry" itemscope itemtype="http://schema.org/BlogPosting">
5+
6+
<header class="post-header">
7+
<h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}</h1>
8+
<p class="post-meta">
9+
<div class="post-dt" style="width:60%; float:left">
10+
<time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">
11+
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
12+
{{ page.date | date: date_format }}
13+
</time>
14+
{%- if page.author -%}
15+
<span itemprop="author" itemscope itemtype="http://schema.org/Person"><span class="p-author h-card" itemprop="name">{{ page.author }}</span></span>
16+
{%- endif -%}
17+
</div>
18+
19+
20+
<div class="post-categories" style="width:40%; float:right">
21+
<div class="post-categories-list" style="display: flex; justify-content: flex-end">
22+
{% if post %}
23+
{% assign categories = post.categories %}
24+
{% else %}
25+
{% assign categories = page.categories %}
26+
{% endif %}
27+
{% for category in categories %}
28+
<a href="{{site.baseurl}}/categories/#{{category|slugize}}">{{category}}</a>
29+
{% unless forloop.last %}&nbsp;{% endunless %}
30+
{% endfor %}
31+
</div>
32+
</div>
33+
34+
</p>
35+
36+
37+
</header>
38+
39+
<div class="post-content e-content" itemprop="articleBody">
40+
{{ content }}
41+
</div>
42+
43+
{%- if site.disqus.shortname -%}
44+
{%- include disqus_comments.html -%}
45+
{%- endif -%}
46+
47+
<a class="u-url" href="{{ page.url | relative_url }}" hidden></a>
48+
</article>

assets/main.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ article.post {
3636
box-shadow: 0 0 0 0, 0 0px 25px rgba(34, 34, 34, 0.15);
3737
border-radius: 3px;
3838
position: relative;
39+
40+
.post-content {
41+
padding-top: 25px;
42+
}
3943
}
4044

4145
section.card {

categories.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
layout: page
3+
permalink: /categories/
4+
title: Categories
5+
---
6+
7+
8+
<div id="archives">
9+
{% for category in site.categories %}
10+
<div class="archive-group">
11+
{% capture category_name %}{{ category | first }}{% endcapture %}
12+
<div id="#{{ category_name | slugize }}"></div>
13+
<p></p>
14+
15+
<h3 class="category-head">{{ category_name }}</h3>
16+
<a name="{{ category_name | slugize }}"></a>
17+
{% for post in site.categories[category_name] %}
18+
<article class="archive-item">
19+
<h4><a href="{{ site.baseurl }}{{ post.url }}">{{post.title}}</a></h4>
20+
</article>
21+
{% endfor %}
22+
</div>
23+
{% endfor %}
24+
</div>

0 commit comments

Comments
 (0)