Skip to content

Commit 16f941f

Browse files
committed
layouts refactored by includes
1 parent 627495b commit 16f941f

10 files changed

+104
-88
lines changed

_includes/header.html

+1-9
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@
88
</div>
99
</a>
1010

11-
<nav class="header__links">
12-
<div class="container header__links-wrapper">
13-
<a class="header__link" href="{{ '/blog' | relative_url }}" itemprop="url"><span itemprop="name">Blog</span></a>
14-
<a class="header__link" href="{{ '/categories' | relative_url }}" itemprop="url"><span itemprop="name">Categories</span></a>
15-
<a class="header__link" href="{{ '/about' | relative_url }}" itemprop="url"><span itemprop="name">About</span></a>
16-
<a class="header__link" href="{{ '/contact' | relative_url }}" itemprop="url"><span itemprop="name">Contact</span>
17-
</a>
18-
</div>
19-
</nav>
11+
{% include navigation.html %}
2012

2113
<div class="header__toggle">
2214
<span></span>

_includes/navigation.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<nav class="header__links">
2+
<div class="container header__links-wrapper">
3+
<a class="header__link" href="{{ '/blog' | relative_url }}" itemprop="url">
4+
<span itemprop="name">Blog</span>
5+
</a>
6+
<a class="header__link" href="{{ '/categories' | relative_url }}" itemprop="url">
7+
<span itemprop="name">Categories</span>
8+
</a>
9+
<a class="header__link" href="{{ '/about' | relative_url }}" itemprop="url">
10+
<span itemprop="name">About</span>
11+
</a>
12+
<a class="header__link" href="{{ '/contact' | relative_url }}" itemprop="url">
13+
<span itemprop="name">Contact</span>
14+
</a>
15+
</div>
16+
</nav>

_includes/post-card-small.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% if post.title != null %}
2+
{% if group == null or group == post.group %}
3+
<li>
4+
<a href="{{ site.url }}{{ post.url }}">{{ post.title }}</a>
5+
<span class="entry-date">
6+
<time datetime="{{ post.date | date_to_xmlschema }}" itemprop="datePublished">{{ post.date | date: "%B %d, %Y" }}</time>
7+
</span>
8+
</li>
9+
{% endif %}
10+
{% endif %}
File renamed without changes.

_includes/post-category.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<h3 id="{{ category[0] }}">{{ category[0] | capitalize }}</h3>
2+
<ul>
3+
{% assign post_list = category[1] %}
4+
5+
{% for post in post_list %}
6+
{% include post-card-small.html %}
7+
{% endfor %}
8+
9+
{% assign post_list = nil %}
10+
{% assign group = nil %}
11+
</ul>

_includes/post-controls.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="post-content controls__inner">
2+
<div class="controls__item prev">
3+
{% if page.previous.url %}
4+
<span>Previous</span>
5+
<a href="{{page.previous.url | relative_url }}">
6+
<i class='fa fa-angle-left'></i>
7+
{{page.previous.title | strip_html | truncate: 30}}
8+
</a>
9+
{% endif %}
10+
</div>
11+
12+
<div class="controls__item next">
13+
{% if page.next.url %}
14+
<span>Next</span>
15+
<a href="{{page.next.url | relative_url }}">
16+
{{page.next.title | strip_html | truncate: 30}}
17+
<i class='fa fa-angle-right'></i>
18+
</a>
19+
{% endif %}
20+
</div>
21+
</div>
22+
</div>

_includes/post-metadata.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<div class="hero__wrap">
2+
3+
<h1 class="hero__title">{{ page.title }}</h1>
4+
<h4 class="hero__category">{{ page.categories }}</h4>
5+
6+
<ul class="hero__tag">
7+
{% for tag in page.tags %}
8+
<li>{{ tag }}</li>
9+
{% endfor %}
10+
</ul>
11+
12+
<p class="hero__meta">
13+
<span>
14+
<time>{{ page.date | date_to_string }} </time>&nbsp; | &nbsp;
15+
</span>
16+
<span>
17+
{% assign words = content | number_of_words %}
18+
{% if words < 360 %}
19+
1 min
20+
{% else %}
21+
{{ words | divided_by:180 }} mins
22+
{% endif %} read
23+
</span>
24+
</p>
25+
</div>

_layouts/blog.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1 class="hero__title">{{ page.title }}</h1>
1818
<div class="post-list" itemscope="" itemtype="http://schema.org/Blog">
1919

2020
{% for post in paginator.posts %}
21-
{% include card.html %}
21+
{% include post-card.html %}
2222
{% endfor %}
2323

2424
</div>

_layouts/post.html

+16-59
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,34 @@
11
<html lang="{{ page.lang | default: site.lang | default: "en_US" }}">
22

3-
{% include head.html %}
3+
{% include head.html %}
44

5-
<body class="site">
5+
<body class="site">
66

7-
{% include header.html %}
7+
{% include header.html %}
88

99
{% if page.image %}
10-
<div class="hero lazyload" data-bg="{{site.url}}/assets/img/posts/{{page.image}}.jpg">
10+
<div class="hero lazyload" data-bg="{{site.url}}/assets/img/posts/{{page.image}}.jpg">
1111
{% else %}
12-
<div class="hero dark-bg">
12+
<div class="hero dark-bg">
1313
{% endif %}
14-
<div class="hero__wrap">
15-
16-
<h1 class="hero__title">{{ page.title }}</h1>
17-
<h4 class="hero__category">{{ page.categories }}</h4>
1814

19-
<ul class="hero__tag">
20-
{% for tag in page.tags %}
21-
<li>{{ tag }}</li>
22-
{% endfor %}
23-
</ul>
15+
{% include post-metadata.html %}
2416

25-
<p class="hero__meta">
26-
<span>
27-
<time>{{ page.date | date_to_string }} </time>&nbsp; | &nbsp;
28-
</span>
29-
<span>
30-
{% assign words = content | number_of_words %}
31-
{% if words < 360 %}
32-
1 min
33-
{% else %}
34-
{{ words | divided_by:180 }} mins
35-
{% endif %} read
36-
</span>
37-
</p>
3817
</div>
39-
</div>
40-
</div>
41-
42-
<main class="site__content">
43-
<div class="container">
44-
<article class="post-content" itemprop="articleBody">
45-
{{ content }}
46-
</article>
18+
</div>
4719

48-
<div class="post-content controls__inner">
49-
<div class="controls__item prev">
50-
{% if page.previous.url %}
51-
<span>Previous</span>
52-
<a href="{{page.previous.url | relative_url }}">
53-
<i class='fa fa-angle-left'></i>
54-
{{page.previous.title | strip_html | truncate: 30}}
55-
</a>
56-
{% endif %}
57-
</div>
20+
<main class="site__content">
21+
<div class="container">
22+
<article class="post-content" itemprop="articleBody">
23+
{{ content }}
24+
</article>
5825

59-
<div class="controls__item next">
60-
{% if page.next.url %}
61-
<span>Next</span>
62-
<a href="{{page.next.url | relative_url }}">
63-
{{page.next.title | strip_html | truncate: 30}}
64-
<i class='fa fa-angle-right'></i>
65-
</a>
66-
{% endif %}
67-
</div>
68-
</div>
69-
</div>
26+
{% include post-controls.html %}
7027

71-
</main>
28+
</main>
7229

73-
{% include footer.html %}
30+
{% include footer.html %}
7431

75-
</body>
32+
</body>
7633

7734
</html>

_pages/categories.md

+2-19
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@ title: Categories
44
permalink: /categories/
55
---
66

7-
{% for tag in site.categories %}
8-
<h3 id="{{ tag[0] }}">{{ tag[0] | capitalize }}</h3>
9-
<ul>
10-
{% assign pages_list = tag[1] %}
11-
{% for post in pages_list %}
12-
{% if post.title != null %}
13-
{% if group == null or group == post.group %}
14-
<li>
15-
<a href="{{ site.url }}{{ post.url }}">{{ post.title }}</a>
16-
<span class="entry-date">
17-
<time datetime="{{ post.date | date_to_xmlschema }}" itemprop="datePublished">{{ post.date | date: "%B %d, %Y" }}</time>
18-
</span>
19-
</li>
20-
{% endif %}
21-
{% endif %}
22-
{% endfor %}
23-
{% assign pages_list = nil %}
24-
{% assign group = nil %}
25-
</ul>
7+
{% for category in site.categories %}
8+
{% include post-category.html %}
269
{% endfor %}

0 commit comments

Comments
 (0)