Skip to content

Commit

Permalink
add functionality to display categories, like tags, in blog home page (
Browse files Browse the repository at this point in the history
…alshedivat#1482)

Added the functionality to display categories on the front page of the
blog, just like tags.
  • Loading branch information
furkanakkurt1335 authored and adityarauniyar committed Jan 17, 2024
1 parent b097561 commit 7ad86f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 13 additions & 2 deletions blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ <h2>{{ site.blog_description }}</h2>
</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>
Expand All @@ -36,6 +36,17 @@ <h2>{{ site.blog_description }}</h2>
<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 %}
Expand Down

0 comments on commit 7ad86f9

Please sign in to comment.