feat: fine-tuning date format, subtitle in post list

This commit is contained in:
zaaarf 2024-01-19 18:47:53 +01:00
parent 913844384b
commit e8addb1d70
No known key found for this signature in database
GPG key ID: 102E445F4C3F829B
6 changed files with 42 additions and 19 deletions

View file

@ -62,6 +62,11 @@ header_nav = [
{ url = "/blog", name_en = "/blog/", name_fr = "/blog/" }
]
# Enable KaTeX for mathematical typesetting.
# Even if you enable it here, you still have to enable it on a per-page
# basis by setting setting extra.math to true.
enable_katex = false
# Homepage configuration stuff
[extra.home]
title = "you"
@ -85,6 +90,7 @@ social_icons = [
# Valid keys are "post" and "list", one referring to individual blogposts,
# the other referring to lists of posts in sections.
# You may set "list" to whitespace(s) to disable displaying dates in sections.
# May be configured on section and page level as well.
# Refer to https://docs.rs/chrono/0.4.31/chrono/format/strftime/index.html
# for formatting instructions.
[extra.date_format]

View file

@ -175,7 +175,11 @@ footer {
text-align: left;
span.content-date {
color: var(--dateLinkColor);
color: var(--darkLinkColor);
}
span.content-subtitle {
color: var(--darkLinkColor);
}
}

View file

@ -83,7 +83,7 @@
--fgColor: {% if config.extra.colors.dark.foreground_color %}{{ config.extra.colors.dark.foreground_color }}{% else %}#D6D6D6{% endif %};
--metaColor: {% if config.extra.colors.dark.meta_color %}{{ config.extra.colors.dark.meta_color }}{% else %}#78B6AD{% endif %};
--linkColor: {% if config.extra.colors.dark.link_color %}{{ config.extra.colors.dark.link_color }}{% else %}#DBD5BC{% endif %};
--dateLinkColor: {% if config.extra.colors.dark.date_link_color %}{{ config.extra.colors.dark.date_link_color }}{% else %}#6F6847{% endif %};
--darkLinkColor: {% if config.extra.colors.dark.dark_link_color %}{{ config.extra.colors.dark.dark_link_color }}{% else %}#6F6847{% endif %};
--codeLineColor: {% if config.extra.colors.dark.code_line_color %}{{ config.extra.colors.dark.code_line_color }}{% else %}#31333d{% endif %};
}
@ -92,7 +92,7 @@
--fgColor: {% if config.extra.colors.light.foreground_color %}{{ config.extra.colors.light.foreground_color }}{% else %}#41474E{% endif %};
--metaColor: {% if config.extra.colors.light.meta_color %}{{ config.extra.colors.light.meta_color }}{% else %}#D26878{% endif %};
--linkColor: {% if config.extra.colors.light.link_color %}{{ config.extra.colors.light.link_color }}{% else %}#5690AF{% endif %};
--dateLinkColor: {% if config.extra.colors.light.date_link_color %}{{ config.extra.colors.light.date_link_color }}{% else %}#223844{% endif %};
--darkLinkColor: {% if config.extra.colors.light.dark_link_color %}{{ config.extra.colors.light.dark_link_color }}{% else %}#223844{% endif %};
--codeLineColor: {% if config.extra.colors.light.code_line_color %}{{ config.extra.colors.light.code_line_color }}{% else %}#FFFFFF{% endif %};
}
</style>

View file

@ -2,13 +2,17 @@
{% block pre_content %}
<div><a href="..">..</a>/<span class="metadata">{{ page.slug }}</span></div>
{% if config.extra.date_format.post %}
{% set datefmt = config.extra.date_format.post %}
{% else %}
{% set datefmt = "%Y-%m-%dT%H:%M:%S%Z" %}
{% endif %}
{%- if page.extra.date_format.post -%}
{%- set datefmt = page.extra.date_format.post -%}
{%- elif section.extra.date_format.post -%}
{%- set datefmt = section.extra.date_format.post -%}
{%- elif config.extra.date_format.post -%}
{%- set datefmt = config.extra.date_format.post -%}
{%- else -%}
{%- set datefmt = "%Y-%m-%dT%H:%M:%S%Z" -%}
{%- endif -%}
<time datetime="{{ page.date }}">Published on: <span class="metadata">{{ page.date | date(format=datefmt) }}</span></time>
{% if config.extra.author and config.extra.display_author == true %}
{%- if config.extra.author and config.extra.display_author == true -%}
<address rel="author">By <span class="metadata">{{config.extra.author}}</span></address>
{% endif %}
{%- endif -%}
{% endblock pre_content %}

View file

@ -12,14 +12,23 @@
{% endif %}
<ul class="title-list">
{% if config.extra.date_format.list %}
{% set datefmt = config.extra.date_format.list %}
{% else %}
{% set datefmt = " @ %Y-%m-%dT%H:%M:%S%Z" %}
{% endif %}
{% for page in pages %}
<li><a href="{{ page.permalink | safe }}">{{ page.title }}<span class="content-date">{{ page.date | date(format=datefmt) }}</span></a></li>
{% endfor %}
{%- for page in pages -%}
{%- if page.extra.date_format.list -%}
{%- set datefmt = page.extra.date_format.list -%}
{%- elif section.extra.date_format.list -%}
{%- set datefmt = section.extra.date_format.list -%}
{%- elif config.extra.date_format.list -%}
{%- set datefmt = config.extra.date_format.list -%}
{%- else -%}
{% set datefmt = " @ %Y-%m-%dT%H:%M:%S%Z" %}
{%- endif -%}
<li><a href="{{ page.permalink | safe }}">{{ page.title }}
{%- if section.extra.show_subtitle and section.extra.show_subtitle == true and page.extra.subtitle -%}
<span class="content-subtitle"> - {{ page.extra.subtitle }}</span>
{%- endif -%}
<span class="content-date">{{ page.date | date(format=datefmt) }}</span>
</a></li>
{%- endfor -%}
</ul>
{% if paginator %}

View file

@ -9,5 +9,5 @@ min_version = "0.4.0"
[author]
name = "zaaaerf"
name = "zaaarf"
homepage = "https://zaaarf.foo/"