feat: rewrite metadata + add changelog link on article

This commit is contained in:
Ungol 2025-12-23 22:27:52 +01:00
parent 8556f360dd
commit c332052930
4 changed files with 66 additions and 12 deletions

View file

@ -0,0 +1,26 @@
{%- set relative_path = page.relative_path -%}
{%- set repository_url = config.extra.remote_repository_url | trim_end_matches(pat='/') -%}
{%- set branch = config.extra.remote_repository_branch | default(value="main") -%}
{%- set git_platform = config.extra.remote_repository_git_platform | default(value="auto") -%}
{# Auto-detect the git platform based on the URL#}
{%- if git_platform == "auto" %}
{%- if repository_url is containing("github.") -%}
{%- set git_platform = "github" -%}
{%- elif repository_url is containing("gitlab.") -%}
{%- set git_platform = "gitlab" -%}
{%- elif repository_url is matching("(gitea\.|codeberg\.)") -%}
{%- set git_platform = "gitea" -%}
{%- endif -%}
{%- endif -%}
{# Generate the commit history URL based on the git platform #}
{%- if git_platform == "github" -%}
{{ repository_url ~ '/commits/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }}
{%- elif git_platform == "gitlab" -%}
{{ repository_url ~ '/-/commits/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }}
{%- elif git_platform in ["gitea", "codeberg"] -%}
{{ repository_url ~ '/commits/branch/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }}
{%- else -%}
{{ throw(message="ERROR: Unknown, unsupported, or unspecified git platform. If you're using a custom domain, please specify the 'git_platform' in the config.") }}
{%- endif -%}

View file

@ -9,18 +9,22 @@
{% endif %}
<p class=metadata>
<span> {{ page.authors | join(sep=', ') }}</span>
|
<span class="separator"></span>
<span>
<meta itemprop="datePublished" content="{{ page.date | date(format='%+') }}">
 {{ page.date | date(format='%d %b %Y') }}
</span>
|
<span class="separator"></span>
<span>󱎫 {{ page.reading_time }} min</span>
</p>
<p class="last-update">
{% if page.updated %}
<span>󰚰 {{ page.updated | date(format='%d %b %Y') }}</span>
|
<span class="separator"></span>
{% if config.extra.remote_repository_url %}
<a class="external-link" href="{% include 'partials/history_url.html'%}" target="_blank" rel="noopener noreferrer">Changements</a>
{% endif %}
{% endif %}
<span>󱎫 {{ page.reading_time }} min</span>
</p>
</section>
<section>