Skip to content

Commit

Permalink
Merge pull request #55 from welpo/fix/title-tag
Browse files Browse the repository at this point in the history
🐛 fix: use set_title macro to set proper titles
  • Loading branch information
welpo authored Feb 22, 2023
2 parents 872992b + 9ac1504 commit ba0631b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{% import "macros/content.html" as macros_content %}
{% import "macros/cards_posts.html" as macros_cards_posts %}
{% import "macros/list_title.html" as macros_list_title %}
{% import "macros/set_title.html" as macros_set_title %}


<!DOCTYPE html>
Expand Down
29 changes: 29 additions & 0 deletions templates/macros/set_title.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% macro set_title() %}

{# Setup. #}
{% set prefix = config.title | safe %}
{% set separator = " • " %}

{% if current_path and current_path == "/" %}
{% set suffix = "" %}
{% set separator = "" %}
{% elif title %}
{% set suffix = title %}
{% elif section.title %}
{% set suffix = section.title %}
{% elif page.title %}
{% set suffix = page.title %}
{% elif term.name %}
{# Individual tags. #}
{% set suffix = term.name ~ " tag" %}
{% elif taxonomy.name %}
{# List of tags. #}
{% set suffix = taxonomy.name | capitalize %}
{% else %}
{% set suffix = "Lost?" %}
{% endif %}

{# Return the final concatenated string. #}
{{ prefix ~ separator ~ suffix}}

{% endmacro page_header %}
14 changes: 1 addition & 13 deletions templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">

{# Site title #}
{% set current_path = current_path | default(value="/") %}
{% if current_path == "/" %}
<title>
{{ config.title | default(value="Home") }}
</title>
{% else %}
<title>
{{ page.title | default(value=config.title) | default(value="Post") }}
</title>
{% endif %}
<title>{{ macros_set_title::set_title() }}</title>

{# Favicon #}
{% if config.extra.favicon %}
<link rel="icon" type="image/png" href={{ config.extra.favicon }} />
{% endif %}



{# RSS #}
<link rel="alternate" type="application/atom+xml" title="{{ config.title }}" href="{{ get_url(path="atom.xml",
trailing_slash=false) }}">
<link rel="stylesheet" type="text/css" media="screen" href={{ get_url(path="main.css" ) }} />


{% if config.extra.stylesheets %}
{% for stylesheet in config.extra.stylesheets %}
<link rel="stylesheet" href="{{ get_url(path=stylesheet) }}">
Expand Down

0 comments on commit ba0631b

Please sign in to comment.