From d99e90d04d93c50ec2bb2802a23465fa52aeba65 Mon Sep 17 00:00:00 2001 From: Deepak Sarda Date: Mon, 26 Dec 2022 16:34:21 +0800 Subject: [PATCH 1/5] Make post summary truncation length configurable --- README.md | 1 + config.toml | 2 ++ templates/blog.html | 2 +- templates/post-preview.html | 4 ++-- templates/tags/single.html | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fc2d22a..bafba79 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ The following options should be under the `[extra]` in `config.toml` - `not_found_message` - the content for your 404 page in markdown - `profile_large` - the path to a larger vertical version of your profile picture in the content folder - `profile_small` - the path to a small version of your profile picture in the content folder +- `summary_truncate_length` - the length of a post's summary ### Page diff --git a/config.toml b/config.toml index 0655883..fac461b 100644 --- a/config.toml +++ b/config.toml @@ -25,6 +25,8 @@ taxonomies = [ dark_mode = false +summary_truncate_length = 300 + nav = [ { name = "About", path = "/about/" }, { name = "Blog", path = "/blog/" } diff --git a/templates/blog.html b/templates/blog.html index ab5d81f..ec8b532 100644 --- a/templates/blog.html +++ b/templates/blog.html @@ -12,6 +12,6 @@ {{ section.content | safe }} {% for post in section.pages %} - {{ post_macros::post_preview(post=post) }} + {{ post_macros::post_preview(post=post, summary_truncate_length=config.extra.summary_truncate_length) }} {% endfor %} {% endblock content %} diff --git a/templates/post-preview.html b/templates/post-preview.html index 82e7d14..ad7a304 100644 --- a/templates/post-preview.html +++ b/templates/post-preview.html @@ -1,4 +1,4 @@ -{% macro post_preview(post) %} +{% macro post_preview(post, summary_truncate_length=300) %}

{{ post.title }}

@@ -8,7 +8,7 @@

{{ post.title }}

{% if post.summary -%} {{ post.summary }} {% else %} - {{ post.content | safe | striptags | truncate(length=300) }} + {{ post.content | truncate(length=summary_truncate_length) | safe }} {%- endif %} read more
diff --git a/templates/tags/single.html b/templates/tags/single.html index 993cff6..52016c0 100644 --- a/templates/tags/single.html +++ b/templates/tags/single.html @@ -12,7 +12,7 @@

{{ term.pages | length }} pages tagged with "{{ term.name }}"

{% for post in term.pages %} - {{ post_macros::post_preview(post=post) }} + {{ post_macros::post_preview(post=post, summary_truncate_length=config.extra.summary_truncate_length) }} {% endfor %}
{% endblock content %} From e28cb05268259d21ddf66585e8c4ae1d14f98a75 Mon Sep 17 00:00:00 2001 From: Deepak Sarda Date: Mon, 26 Dec 2022 17:33:20 +0800 Subject: [PATCH 2/5] Add support for authors taxonomy --- README.md | 6 ++++-- templates/blog-post.html | 12 ++++++++++-- templates/{tags/list.html => taxonomy_list.html} | 0 templates/{tags/single.html => taxonomy_single.html} | 0 4 files changed, 14 insertions(+), 4 deletions(-) rename templates/{tags/list.html => taxonomy_list.html} (100%) rename templates/{tags/single.html => taxonomy_single.html} (100%) diff --git a/README.md b/README.md index bafba79..98032f7 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,11 @@ You can find installation instructions [on the Zola website](https://www.getzola 4. This theme uses the `tags` taxonomy, in your `config.toml` file set `taxonomies = [ { name = "tags" } ]` -5. Copy across the default content from the theme by running `cp themes/simple-dev-blog/content/* ./content -r` +5. This theme uses the `authors` taxonomy, in your `config.toml` file set `taxonomies = [ { name = "authors" } ]` -6. That's it! Now build your site by running the following command, and navigate to `127.0.0.1:111`: +6. Copy across the default content from the theme by running `cp themes/simple-dev-blog/content/* ./content -r` + +7. That's it! Now build your site by running the following command, and navigate to `127.0.0.1:111`: ```sh zola serve diff --git a/templates/blog-post.html b/templates/blog-post.html index ff83ffb..6707cdb 100644 --- a/templates/blog-post.html +++ b/templates/blog-post.html @@ -74,11 +74,19 @@

{{ page.title }}

{{ page.date | date(format="%B %d, %Y") }} + {% if page.taxonomies.authors %} + — By + + {% for author in page.taxonomies.authors %} + {{ author }}{% if not loop.last %}, {% endif %} + {% endfor %} + + {% endif %} {% if page.taxonomies.tags %} - - + — Filed under {% for tag in page.taxonomies.tags %} - {{ tag }} + {{ tag }}{% if not loop.last %}, {% endif %} {% endfor %} {% endif %} diff --git a/templates/tags/list.html b/templates/taxonomy_list.html similarity index 100% rename from templates/tags/list.html rename to templates/taxonomy_list.html diff --git a/templates/tags/single.html b/templates/taxonomy_single.html similarity index 100% rename from templates/tags/single.html rename to templates/taxonomy_single.html From e6acd4a90b6bdecb59ec7d474be3dfa8713c501e Mon Sep 17 00:00:00 2001 From: Deepak Sarda Date: Fri, 24 Mar 2023 16:20:49 +0800 Subject: [PATCH 3/5] Fix legibility of index page --- sass/main.scss | 9 ++++++++- sass/text.scss | 2 +- templates/blog-post.html | 4 ++-- templates/post-preview.html | 9 +++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sass/main.scss b/sass/main.scss index 0fa128f..f6e19be 100644 --- a/sass/main.scss +++ b/sass/main.scss @@ -6,7 +6,7 @@ body { } .post-preview { - h3.post-title { + h2.post-title { margin-bottom: 0; } @@ -108,3 +108,10 @@ table tbody tr:nth-of-type(even) { table tbody tr:last-of-type { border-bottom: 2px solid var(--accent-color); } + +hr.gradient-line { + height: 2px; + border: none; + border-radius: 10px; + background-image: linear-gradient(to right, #ffffff, var(--accent-color)); +} diff --git a/sass/text.scss b/sass/text.scss index 87c7275..708a0ae 100644 --- a/sass/text.scss +++ b/sass/text.scss @@ -62,7 +62,7 @@ a:visited { main { max-width: 700px; - padding-top: 8rem; + padding-top: 4rem; margin: auto; } diff --git a/templates/blog-post.html b/templates/blog-post.html index 6707cdb..383cbcd 100644 --- a/templates/blog-post.html +++ b/templates/blog-post.html @@ -75,7 +75,7 @@

{{ page.title }}

{{ page.date | date(format="%B %d, %Y") }} {% if page.taxonomies.authors %} - — By +  ·  By {% for author in page.taxonomies.authors %} {{ author }}{% if not loop.last %}, {% endif %} @@ -83,7 +83,7 @@

{{ page.title }}

{% endif %} {% if page.taxonomies.tags %} - — Filed under +  ·  Filed under {% for tag in page.taxonomies.tags %} {{ tag }}{% if not loop.last %}, {% endif %} diff --git a/templates/post-preview.html b/templates/post-preview.html index ad7a304..c4d808b 100644 --- a/templates/post-preview.html +++ b/templates/post-preview.html @@ -1,16 +1,17 @@ {% macro post_preview(post, summary_truncate_length=300) %}
-

{{ post.title }}

+

{{ post.title }}

- {{ post.date| date(format="%B %d, %Y") }} - {{ post.word_count }} words - {{ post.reading_time }} mins + {{ post.date| date(format="%B %d, %Y") }}  ·  {{ post.word_count }} words  ·  {{ post.reading_time }} mins
{% if post.summary -%} - {{ post.summary }} + {{ post.summary | safe }} {% else %} {{ post.content | truncate(length=summary_truncate_length) | safe }} {%- endif %} - read more +

continue reading …

+
{% endmacro input %} From 31adc07b1100c6d75f2cce7f42fc3903b5f53c44 Mon Sep 17 00:00:00 2001 From: Deepak Sarda Date: Fri, 24 Mar 2023 16:21:26 +0800 Subject: [PATCH 4/5] Fix pluralization of title in taxonomy pages --- templates/taxonomy_single.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html index 52016c0..ee95065 100644 --- a/templates/taxonomy_single.html +++ b/templates/taxonomy_single.html @@ -9,7 +9,7 @@ {% endblock posthead %} {% block content %} -

{{ term.pages | length }} pages tagged with "{{ term.name }}"

+

{{ term.pages | length }} page{{ term.pages | length | pluralize }} tagged with "{{ term.name }}"

{% for post in term.pages %} {{ post_macros::post_preview(post=post, summary_truncate_length=config.extra.summary_truncate_length) }} From d84ec3d0fa30d11b0aae0a1d24be5281aef91e78 Mon Sep 17 00:00:00 2001 From: Deepak Sarda Date: Fri, 24 Mar 2023 17:45:35 +0800 Subject: [PATCH 5/5] Display site title in the top header --- sass/text.scss | 6 ++++++ templates/base.html | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sass/text.scss b/sass/text.scss index 708a0ae..153f456 100644 --- a/sass/text.scss +++ b/sass/text.scss @@ -110,6 +110,7 @@ header { margin: auto; display: flex; flex-direction: row; + align-items: center; } a.profile-icon { @@ -123,6 +124,11 @@ a.profile-icon { } } +.profile-text { + padding-left: 1rem; + font-size: 1.5rem; +} + nav { display: flex; align-items: center; diff --git a/templates/base.html b/templates/base.html index 58eca02..5af1045 100644 --- a/templates/base.html +++ b/templates/base.html @@ -108,7 +108,7 @@ {% block title %} {% if page.title %} - {{ page.title }} + {{ page.title | striptags }} :: {{ config.title }} {% else %} {{ config.title }} {% endif %} @@ -127,6 +127,7 @@ <a class="profile-icon" href="/"> <img src="{{ icon.url }}" alt="profile picture"> </a> + <span class="profile-text">{{ config.title }}</span> <nav> {% for link in config.extra.nav %} <a href="{{ link.path }}">{{ link.name }}</a>