Skip to content

Commit

Permalink
Slight blog index redesign.
Browse files Browse the repository at this point in the history
- Include links to month indices on year pages
- Prefix page titles with "Index:"
  • Loading branch information
mayo committed Jul 18, 2024
1 parent 1336c79 commit ac5f1e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion templates/blog/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h2>Starting Points</h2>
{% endfor %}
</dd>

<dt>Years</dt>
<dt>Index by year</dt>
<dd>
{% for year_section in archive_list.subsections | sort | reverse %}
{% set year = get_section(path=year_section, metadata_only=true) %}
Expand Down
17 changes: 17 additions & 0 deletions templates/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@
{% block template_vars %}
{{super()}}
{% set page_title = macros::section_path_title(node=node) %}

{% if section.path is starting_with("/blog/") %}
{% set page_title = "Index: " ~ page_title %}
{% endif %}
{% endblock template_vars %}

{% block page_content %}

{% set sort_attribute = "title" %}
{% if section.path is starting_with("/blog/") %}
{% set sort_attribute = "date" %}

{%- set is_blog_year_index = node.components | length == 2 -%}
{%- if is_blog_year_index %}
<dl class="key-value-twoline">
<dt>Index by month</dt>
<dd>
{% for month_section in node.subsections | sort %}
{% set month = get_section(path=month_section) %}
<a href="{{ month.path }}">{{ month.components[1] ~ "-" ~ month.components[2] ~ "-01" | date(format="%B") }}</a>
{% endfor %}
</dd>
</dl>
{%- endif -%}
{% endif %}

{{ macros::collection_list(collection=node.pages | sort(attribute=sort_attribute)) }}
Expand Down

0 comments on commit ac5f1e8

Please sign in to comment.