add functionality to display categories, like tags, in blog home page (#1482)

Added the functionality to display categories on the front page of the
blog, just like tags.
This commit is contained in:
Furkan Akkurt 2023-06-20 02:11:41 +03:00 committed by GitHub
parent aeee609c92
commit 4d955518bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -263,6 +263,7 @@ jekyll-archives:
category: '/blog/category/:name/'
display_tags: ['formatting', 'images', 'links', 'math', 'code'] # these tags will be displayed on the front page of your blog
display_categories: ['blockquotes'] # these categories will be displayed on the front page of your blog
# -----------------------------------------------------------------------------
# Jekyll Scholar

View File

@ -404,7 +404,7 @@ footer.sticky-bottom {
}
}
.tag-list {
.tag-category-list {
border-bottom: 1px solid var(--global-divider-color);
text-align: center;
padding-top: 1rem;

View File

@ -25,8 +25,8 @@ pagination:
</div>
{% endif %}
{% if site.display_tags %}
<div class="tag-list">
{% if site.display_tags or site.display_categories %}
<div class="tag-category-list">
<ul class="p-0 m-0">
{% for tag in site.display_tags %}
<li>
@ -36,6 +36,17 @@ pagination:
<p>&bull;</p>
{% endunless %}
{% endfor %}
{% if site.display_categories.size > 0 and site.display_tags.size > 0 %}
<p>&bull;</p>
{% endif %}
{% for category in site.display_categories %}
<li>
<i class="fas fa-tag fa-sm"></i> <a href="{{ category | slugify | prepend: '/blog/category/' | relative_url }}">{{ category }}</a>
</li>
{% unless forloop.last %}
<p>&bull;</p>
{% endunless %}
{% endfor %}
</ul>
</div>
{% endif %}