From 18664118c08300b0e4a82ac225cc62b8b1513a7f Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 24 Oct 2022 20:36:56 +0200 Subject: categories: redesign Re-use some of posts includes so that categories pages look much cooler. --- _includes/jekyll-theme/categories/all.html | 25 +++++++++++++------------ _includes/jekyll-theme/categories/category.html | 13 +++++++------ _includes/jekyll-theme/categories/label.html | 6 ++++++ _includes/jekyll-theme/posts/feed.html | 2 +- _includes/jekyll-theme/posts/header.html | 23 +++++++---------------- _layouts/post.html | 2 +- code/index.html | 1 + features/index.html | 1 + 8 files changed, 37 insertions(+), 36 deletions(-) create mode 100644 _includes/jekyll-theme/categories/label.html diff --git a/_includes/jekyll-theme/categories/all.html b/_includes/jekyll-theme/categories/all.html index 82efce5..d1c6285 100644 --- a/_includes/jekyll-theme/categories/all.html +++ b/_includes/jekyll-theme/categories/all.html @@ -3,20 +3,21 @@ {% else %} {% assign categories = site.categories | sort %} {% for category in categories %} -

{{ category[0] }}

- + {% assign category_name = category[0] %} +

{% include jekyll-theme/categories/label.html category=category_name %}

+ {% for post in category[1] %} + + {% include jekyll-theme/posts/header.html feed=true title=post.title date=post.date %} + + {% endfor %} {% endfor %} {% assign uncategorized = site.posts | where_exp: "post","post.categories.size == 0" %} {% if uncategorized.size != 0 %} -

Other

- +

{% include jekyll-theme/categories/label.html category="Other" feed=true %}

+ {% for post in uncategorized %} + + {% include jekyll-theme/posts/header.html feed=true title=post.title date=post.date %} + + {% endfor %} {% endif %} {% endif %} diff --git a/_includes/jekyll-theme/categories/category.html b/_includes/jekyll-theme/categories/category.html index f7b7a8c..a33fd76 100644 --- a/_includes/jekyll-theme/categories/category.html +++ b/_includes/jekyll-theme/categories/category.html @@ -1,11 +1,12 @@ -

This is a list of posts in category "{{ include.category }}".

+

{% include jekyll-theme/categories/label.html category=include.category feed=true %}

{% if site.categories[include.category].size > 0 %} - + {% for post in site.categories[include.category] %} + + {% include jekyll-theme/posts/header.html feed=true title=post.title date=post.date %} + + {% endfor %} {% endif %} {% if include.archive_link %}

For a complete list of posts grouped by category, please see this page.

+ {% include jekyll-theme/sidebar/sep.html %} {% endif %} diff --git a/_includes/jekyll-theme/categories/label.html b/_includes/jekyll-theme/categories/label.html new file mode 100644 index 0000000..4345df2 --- /dev/null +++ b/_includes/jekyll-theme/categories/label.html @@ -0,0 +1,6 @@ +  +{%- if include.feed -%} + {{ include.category | downcase }} +{%- else -%} + {{ include.category | downcase }} +{%- endif -%} diff --git a/_includes/jekyll-theme/posts/feed.html b/_includes/jekyll-theme/posts/feed.html index 7f5c0c6..1fff024 100644 --- a/_includes/jekyll-theme/posts/feed.html +++ b/_includes/jekyll-theme/posts/feed.html @@ -3,7 +3,7 @@ {% else %} {% for post in paginator.posts %} - {% include jekyll-theme/posts/header.html feed=true %} + {% include jekyll-theme/posts/header.html feed=true title=post.title date=post.date category=post.category %} {% endfor %} {% include jekyll-theme/posts/paginator.html %} diff --git a/_includes/jekyll-theme/posts/header.html b/_includes/jekyll-theme/posts/header.html index eabb22c..9acea37 100644 --- a/_includes/jekyll-theme/posts/header.html +++ b/_includes/jekyll-theme/posts/header.html @@ -2,30 +2,21 @@ {% if include.feed %}
{{ include.title }}
{% else %} - {% assign post = page %} -

{{ post.title }}

+

{{ include.title }}

{% endif %} +

{%- comment -%} Collapse the Liquid whitespace here, so that no extra spaces between s are introduced. {%- endcomment -%} - {%- if post.category -%} -   - {%- if include.feed -%} - - {%- else -%} - - {%- endif -%} - {{ post.category }} - {%- if include.feed -%} - - {%- else -%} - - {%- endif -%} + {%- if include.category -%} + {% include jekyll-theme/categories/label.html category=include.category feed=include.feed %} + {%- endif -%} + {%- if include.date -%} +  {{ include.date | date: '%d-%b-%Y' }} {%- endif -%} -  {{ post.date | date: '%d-%b-%Y' }}

diff --git a/_layouts/post.html b/_layouts/post.html index 6ac37f7..674b810 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -1,6 +1,6 @@ --- layout: default --- -{% include jekyll-theme/posts/header.html %} +{% include jekyll-theme/posts/header.html title=page.title date=page.date category=page.category %} {{ content }} {% include jekyll-theme/sidebar/sep.html %} diff --git a/code/index.html b/code/index.html index 002a9a5..ed70911 100644 --- a/code/index.html +++ b/code/index.html @@ -1,4 +1,5 @@ --- title: Code +layout: default --- {% include jekyll-theme/categories/category.html category=page.title archive_link='/archive/' %} diff --git a/features/index.html b/features/index.html index 3bd02e3..fd9e61d 100644 --- a/features/index.html +++ b/features/index.html @@ -1,4 +1,5 @@ --- title: Features +layout: default --- {% include jekyll-theme/categories/category.html category=page.title archive_link='/archive/' %} -- cgit v1.2.3