fix: use my own forge to link to articles changes

This commit is contained in:
Ungol 2025-12-23 22:27:52 +01:00
parent 2f64ae0402
commit f997e5d16e
2 changed files with 4 additions and 15 deletions

View file

@ -21,6 +21,6 @@ paths = "safe"
anchor = "safe" anchor = "safe"
[extra] [extra]
remote_repository_url = "https://forge.kworld.fr/Ungol/blog" remote_repository_url = "https://forge.ungol.fr/Ungol/blog"
remote_repository_branch = "main" remote_repository_branch = "main"
remote_repository_git_platform = "gitlab" remote_repository_git_platform = "forgejo"

View file

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