-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: generate commit history URL for updated articles
- Introduce the `create_history_url` macro in Tera to generate URLs. - Add TOML configuration for specifying remote repository details. - Integrate the new feature in the page meta for displaying a link to view changes.
- Loading branch information
Showing
5 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% macro create_history_url(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("gitea.") %} | ||
{% set git_platform = "gitea" %} | ||
{% elif repository_url is containing("gitlab.") %} | ||
{% set git_platform = "gitlab" %} | ||
{% 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 == "gitea" %} | ||
{{ repository_url ~ '/commits/branch/' ~ branch ~ '/' }}{{ relative_path | urlencode }} | ||
{% elif git_platform == "gitlab" %} | ||
{{ repository_url ~ '/-/commits/' ~ branch ~ '/' }}{{ relative_path | urlencode }} | ||
{% else %} | ||
{# Throw an error with a direct link to report a bug for unsupported or unspecified platforms #} | ||
{{ throw(message="ERROR: Unknown, unsupported, or unspecified git platform. If you're using a custom domain, please specify the 'git_platform' in the config. If you think this is a bug, report it [here](https://github.com/welpo/tabi/issues/new?assignees=&labels=bug&template=bug_report.md&title=Unsupported%20Git%20Platform%20Detected).") }} | ||
{% endif %} | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters