Skip to content

Commit 91afdd3

Browse files
committed
Functionality-for-blog-to-be-part-of-series
1 parent 8d55826 commit 91afdd3

File tree

9 files changed

+69
-46
lines changed

9 files changed

+69
-46
lines changed

content/blog/series/contents.lr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
_model: blog-series
1+
_model: blog-series-list

models/blog-series-list.ini

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[model]
2+
name = Blog Series List
3+
label = Blog Series List
4+
hidden = yes
5+
protected = yes
6+
7+
[children]
8+
model = blog-series
9+
order_by = name

models/blog-series.ini

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[model]
2-
name = Blog Series
3-
label = Blog Series
2+
name = Single Series
3+
label = {{ this.name }}
44
hidden = yes
5-
protected = yes
65

76
[children]
8-
model = single-series
9-
order_by = name
7+
replaced_with = site.query(this.parent.parent.path + '/entries').filter(F.series.contains(this))
8+
9+
[fields.name]
10+
label = Name
11+
type = string

models/single-series.ini

-11
This file was deleted.

templates/blog-post.html

+35-7
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22

33
{% from "macros/author_name.html" import render_author_name %}
44

5+
{% from "macros/posts.html" import render_posts %}
6+
57
{% set author = this.parent.parent.children.get('authors').children.get(this.author) %}
68

9+
{% set series = this.parent.parent.children.get('series').children.get(this.series) %}
10+
711
{% block title %}{{ this.title }}{% endblock %}
812
{% block header %}{{ this.parent.title }}{% endblock %}
913
{% block body %}
1014
<h2 class="mb-0">{{ this.title }}</h2>
15+
{{ check_file('content' + this.parent.parent.path + '/authors/' + this.author + '/contents.lr') }}
16+
<p class="meta text-muted mt-0 mb-2">by <a href="{{ author|url }}">{{ render_author_name(author) }}</a>
17+
on {{ this.pub_date|dateformat('EEEE, yyyy-''MM-d') }}</p>
1118
{% if this.series|length %}
12-
<div class="card bg-light">
19+
<div class="card bg-light mb-2">
1320
<div class="card-body p-2">
14-
<p class="meta my-0"><span class="mr-2"><strong>This blog is part of the series :</strong></span>
15-
<a href="/blog/series/{{this.series}}/">{{ this.series }}</a>
21+
<p class="meta my-0"><span class="mr-2"><strong>This blog is part of the series:</strong></span>
22+
<a href="#series">{{ this.series }}</a>
1623
</p>
1724
</div>
1825
</div>
1926
{% endif %}
20-
21-
{{ check_file('content' + this.parent.parent.path + '/authors/' + this.author + '/contents.lr') }}
22-
<p class="meta text-muted mt-0">by <a href="{{ author|url }}">{{ render_author_name(author) }}</a>
23-
on {{ this.pub_date|dateformat('EEEE, yyyy-''MM-d') }}</p>
2427
<div class="body">{{ this.body }}</div>
2528
<div class="card bg-light">
2629
<div class="card-body p-2">
@@ -37,5 +40,30 @@ <h2 class="mb-0">{{ this.title }}</h2>
3740
</p>
3841
</div>
3942
</div>
43+
{% if this.series|length %}
44+
<table class="table table-sm table-striped mt-3" id="series">
45+
<thead class="thead-dark">
46+
<tr>
47+
<th>
48+
All posts under the Series "<span style="font-size:1.15rem">{{ this.series }}<span>"
49+
</th>
50+
</tr>
51+
</thead>
52+
<tbody>
53+
{% for post in series.children %}
54+
{% set author = post.parent.parent.children.get('authors').children.get(post.author) %}
55+
<tr>
56+
<td>
57+
<a href="{{ post|url }}">{{ post.title }}</a>
58+
<p class="text-muted small">by <a href="{{ author|url }}">{{ render_author_name(author) }}</a>
59+
on {{ post.pub_date|dateformat("YYYY-MM-dd") }}</p>
60+
</td>
61+
</tr>
62+
{% endfor %}
63+
</tbody>
64+
</table>
65+
<hr>
66+
Check out <strong><a href="/blog/series/">All Series</a></strong>
67+
{% endif %}
4068
<div class="comments">{{ render_disqus_comments() }}</div>
4169
{% endblock %}

templates/blog-series-list.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends "layout.html" %}
2+
{% from "macros/categories.html" import render_categories %}
3+
{% block title %}{{ this.parent.children.get('entries').title }}{% endblock %}
4+
{% block header %}{{ this.parent.children.get('entries').title }}{% endblock %}
5+
{% block body %}
6+
<h2>All Series</h2>
7+
{{ render_categories(this) }}
8+
{% endblock %}

templates/blog-series.html

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{% extends "layout.html" %}
2-
{% from "macros/categories.html" import render_categories %}
3-
{% block title %}{{ this.parent.children.get('entries').title }}{% endblock %}
4-
{% block header %}{{ this.parent.children.get('entries').title }}{% endblock %}
2+
3+
{% from "macros/posts.html" import render_posts %}
4+
5+
{% block title %}{{ this.name + ' - ' + this.parent.parent.children.get('entries').title }}{% endblock %}
6+
{% block header %}{{ this.parent.parent.children.get('entries').title }}{% endblock %}
57
{% block body %}
6-
<h2>All Series</h2>
7-
{{ render_categories(this) }}
8+
<h2>All posts under Series "{{ this.name }}"</h2>
9+
{{ render_posts(this.children) }}
10+
<hr>
11+
<strong><a href="{{ this.parent|url }}">All Series</a></strong>
812
{% endblock %}

templates/macros/posts.html

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
{% set author = post.parent.parent.children.get('authors').children.get(post.author) %}
77
<li>
88
<a href="{{ post|url }}">{{ post.title }}</a>
9-
{% if post.series|length %}
10-
<p class="meta my-0"><span class="mr-2"><strong>This blog is part of the series :</strong></span>
11-
<a class="badge badge-secondary" href="/blog/series/{{post.series}}/">{{ post.series }}</a>
12-
</p>
13-
{% endif %}
149
<p class="text-muted small">by <a href="{{ author|url }}">{{ render_author_name(author) }}</a>
1510
on {{ post.pub_date|dateformat("YYYY-MM-dd") }}</p>
1611
</li>

templates/single-series.html

-12
This file was deleted.

0 commit comments

Comments
 (0)