Skip to content

Commit 175a56d

Browse files
committed
feat: Blog:
- enable blog in menu - add continue reading and use zola's post preview - add Table of contents options for blog posts - youtube custom scss for responsible full-width Signed-off-by: Lachezar Lechev <[email protected]>
1 parent c74e833 commit 175a56d

File tree

8 files changed

+86
-13
lines changed

8 files changed

+86
-13
lines changed

content/blog/YYYY-MM-DD-Draft-blog-post.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ title = "Your blog post title"
77
description = "Description of your blog post for the blog listing"
88
# The date is set by the filename but we need to use it here,
99
# as the file does not contain a valid date "YYYY-MM-DD"
10+
# This is not required if the filename contains a valid format!
1011
date = "2022-01-01"
1112
# Is it still a draft?
1213
draft = true
14+
1315
[extra]
1416

15-
# Show a quote (first 300 characters) from the content of the blog
16-
# The quote shows below the description.
17-
show_quote = false
17+
# Show a "Table of contents" before the content of the blog post
18+
show_toc = true
1819

1920
[[extra.author]]
2021
name = "The AeroRust community"
@@ -24,4 +25,9 @@ twitter = "AeroRust"
2425
github = "AeroRust"
2526
+++
2627

27-
Text of your blog
28+
Text of your blog goes here...
29+
30+
If you want to add a "Continue Reading" link with a partial quote from the blog post in the list of blog posts, add this line where you want the quote to end:
31+
<!-- more -->
32+
33+
And continue with your blog post content here.

content/blog/_index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ aspects of the development of such systems.
66
You will also find updates on current and future efforts, projects, events happening in the community.
77
"""
88
template = "blog.html"
9-
draft = true
109
paginate_by = 12
1110
sort_by = "date"
1211
page_template = "blog_post.html"

frontend/scss/main.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,21 @@
5050
.card-header a, .card-title a {
5151
text-decoration: none;
5252
}
53+
}
54+
55+
.youtube {
56+
position: relative;
57+
padding-bottom: 56.10%;
58+
height: 0;
59+
overflow: hidden;
60+
}
61+
62+
.youtube iframe,
63+
.youtube object,
64+
.youtube embed {
65+
position: absolute;
66+
top: 0;
67+
left: 0;
68+
width: 100%;
69+
height: 100%;
5370
}

templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
gtag('config', '{{ config.extra.google_tag }}');
3232
</script>
3333
{% endif -%}
34+
3435
</head>
3536

3637
<body>

templates/blog.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ <h2 class="blog-post-title mb-1"><a href="{{ post.permalink | safe }}">{{ post.t
3232
<p>{{ post.description }}</p>
3333

3434
{# <blockquote class="blockquote"> #}
35-
{% if post.extra.show_quote %}
35+
{% if post.summary %}
3636
<p class="fst-italic">
37-
"{{ post.content | striptags | truncate(length=300) }}..."
37+
"{{ post.summary | striptags }}" <a href="{{ post.permalink }}#continue-reading">Continue Reading</a>
3838
</p>
3939
{% endif %}
4040
{# </blockquote> #}

templates/blog_post.html

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,43 @@
77
<div class="row gx-5 mt-3">
88
<div class="col-md-8">
99
<article class="blog-post">
10-
<h1 class="blog-post-title pb-4 mb-4 fst-italic border-bottom">{{ page.title }}</h1>
11-
<p class="blog-post-meta">{{ page.date | date(format="%B %e, %Y") }} by
12-
{{ authors::comma_separated(authors=page.extra.author) }}
13-
</p>
14-
{{ page.content | safe }}
10+
<h1 class="blog-post-title pb-4 mb-4 fst-italic border-bottom">{{ page.title }}</h1>
11+
<p class="blog-post-meta">{{ page.date | date(format="%B %e, %Y") }} ·
12+
{{ authors::comma_separated(authors=page.extra.author) }}
13+
</p>
14+
15+
{% if page.extra.show_toc %}
16+
{% if page.toc %}
17+
Table of contents:
18+
<ul>
19+
{% for h1 in page.toc %}
20+
<li>
21+
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
22+
{% if h1.children %}
23+
<ul>
24+
{% for h2 in h1.children %}
25+
<li>
26+
<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
27+
{% if h2.children %}
28+
<ul>
29+
{% for h3 in h2.children %}
30+
<li>
31+
<a href="{{ h3.permalink | safe }}">{{ h3.title }}</a>
32+
</li>
33+
{% endfor %}
34+
</ul>
35+
{% endif %}
36+
</li>
37+
{% endfor %}
38+
</ul>
39+
{% endif %}
40+
</li>
41+
{% endfor %}
42+
</ul>
43+
{% endif %}
44+
{% endif %}
45+
46+
{{ page.content | safe }}
1547
</article>
1648
</div>
1749

templates/partials/menu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</a>
1919
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 mb-md-0">
2020
<li><a href="{{ get_url(path="@/_index.md") }}" class="nav-link px-2 text-white{% if get_url(path="@/_index.md") | as_str == current_url %} fw-bold{% endif %}">Home</a></li>
21-
{# <li><a href="{{ get_url(path="@/blog/_index.md") }}" class="nav-link px-2 text-white{% if get_url(path="@/blog/_index.md") | as_str == current_url %} fw-bold{% endif %}">Blog</a></li> #}
21+
<li><a href="{{ get_url(path="@/blog/_index.md") }}" class="nav-link px-2 text-white{% if get_url(path="@/blog/_index.md") | as_str == current_url %} fw-bold{% endif %}">Blog</a></li>
2222
<li><a href="{{ get_url(path="@/catalogue/_index.md") }}" class="nav-link px-2 text-white{% if get_url(path="@/catalogue/_index.md") | as_str == current_url %} fw-bold{% endif %}">Are we in space yet?</a></li>
2323
{# <li><a href="{{ get_url(path="@/catalogue/crates.md") }}" class="nav-link px-2 text-white{% if get_url(path="@/catalogue/crates.md") | as_str == current_url %} fw-bold{% endif %}">Crates</a></li> #}
2424
</ul>

templates/shortcodes/toc.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{% if page.toc %}
2+
<ul>
3+
{% for h1 in page.toc %}
4+
<li>
5+
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
6+
{% if h1.children %}
7+
<ul>
8+
{% for h2 in h1.children %}
9+
<li>
10+
<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
11+
</li>
12+
{% endfor %}
13+
</ul>
14+
{% endif %}
15+
</li>
16+
{% endfor %}
17+
</ul>
18+
{% endif %}

0 commit comments

Comments
 (0)