Skip to content

Commit

Permalink
Fix wrong body_class values in archives, authors, categories, pages a…
Browse files Browse the repository at this point in the history
…nd tags templates (#104)

* fix: correct body_class in archives, authors, categories, pages and tags HTML

* Revert "fix: correct body_class in archives, authors, categories, pages and tags HTML"

This reverts commit a1b5b25.

* fix: delete useless modification and correct body_class in base.html

* Changes in current_url for tags and categories

---------

Co-authored-by: Arul <[email protected]>
  • Loading branch information
Tseing and arulrajnet authored May 3, 2024
1 parent bc49578 commit ab26570
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 39 deletions.
81 changes: 44 additions & 37 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,48 +147,55 @@
{% endblock head %}

</head>
{% set body_class='home-template' %}
{% set current_url='/' %}
{% set current_title=SITENAME %}

{% if article %}
{% set body_class='post-template' %}
{% set current_url='/'+article.url %}
{% set current_title=article.title %}
{% endif %}

{% if tag %}
{% set body_class='tag-template' %}
{% set current_url='/'+tag.url %}
{% set current_title='Tag '+tag.name %}
{% endif %}
{% if body_class %}
{% set body_class=body_class %}

{% if category %}
{% set body_class='category-template' %}
{% set current_url='/'+category.url %}
{% set current_title='Category '+category.name %}
{% endif %}
{% else %}
{% set body_class='home-template' %}
{% set current_url='/' %}
{% set current_title=SITENAME %}

{% if page %}
{% set body_class='page-template' %}
{% set current_url='/'+page.url %}
{% set current_title=page.title %}
{% endif %}
{% if article %}
{% set body_class='post-template' %}
{% set current_url='/'+article.url %}
{% set current_title=article.title %}
{% endif %}

{% if author %}
{% set body_class='author-template' %}
{% set current_url='/'+author.url %}
{% set current_title='Author '+author.name %}
{% endif %}
{% if tag %}
{% set body_class='tag-template' %}
{% set current_url='/'+tag.url %}
{% set current_title='Tag '+tag.name %}
{% endif %}

{% if category %}
{% set body_class='category-template' %}
{% set current_url='/'+category.url %}
{% set current_title='Category '+category.name %}
{% endif %}

{% if page %}
{% set body_class='page-template' %}
{% set current_url='/'+page.url %}
{% set current_title=page.title %}
{% endif %}

{% if author %}
{% set body_class='author-template' %}
{% set current_url='/'+author.url %}
{% set current_title='Author '+author.name %}
{% endif %}

{% if period and period_num %}
{% if period_num[2] %}
{% set current_url='/{0}/{1}/{2}/'.format(period_num[0],period_num[1],period_num[2]) %}
{% elif period_num[1] %}
{% set current_url='/{0}/{1}/'.format(period_num[0],period_num[1]) %}
{% elif period_num[0] %}
{% set current_url='/{0}/'.format(period_num[0]) %}
{% endif %}
{% endif %}

{% if period and period_num %}
{% if period_num[2] %}
{% set current_url='/{0}/{1}/{2}/'.format(period_num[0],period_num[1],period_num[2]) %}
{% elif period_num[1] %}
{% set current_url='/{0}/{1}/'.format(period_num[0],period_num[1]) %}
{% elif period_num[0] %}
{% set current_url='/{0}/'.format(period_num[0]) %}
{% endif %}
{% endif %}

<body class="{{body_class}}">
Expand Down
2 changes: 1 addition & 1 deletion templates/categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

{% if categories %}
{% set body_class='categories-template' %}
{% set current_url=CATEGORIES_URL %}
{% set current_url='/'+CATEGORIES_URL %}
{% set current_title=SITENAME+' - Categories' %}
{% set current_display_title='Categories' %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

{% if tags %}
{% set body_class='tags-template' %}
{% set current_url=TAGS_URL %}
{% set current_url='/'+TAGS_URL %}
{% set current_title=SITENAME+' - Tags' %}
{% set current_display_title='Tags' %}
{% endif %}
Expand Down

0 comments on commit ab26570

Please sign in to comment.