Skip to content

Commit

Permalink
feat(footer): add commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesrocket committed Jun 6, 2024
1 parent 3c09c81 commit ba71c93
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ links = [
[extra.footer]
enabled = true
copyright = true
hash = true
stack = true

[extra.social]
Expand Down
21 changes: 16 additions & 5 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
{%- import "macros/macros.html" as macros %}
{% set categories = get_taxonomy(kind="categories") %}
{% set tags = get_taxonomy(kind="tags") %}
{% set active_path = current_path | default(value="none") %}
{%- set tags = get_taxonomy(kind="tags") %}
{%- set active_path = current_path | default(value="none") %}
{%- set hash = "" %}

{%- if config.extra.footer.hash == true%}
{%- set head_branch = load_data(path=".git/HEAD") | replace(from="ref: ", to="") %}
{#- load_data(path=head_branch_path)v is not working #}
{%- if head_branch is containing("refs/heads/trunk") %}
{%- set_global hash = load_data(path=".git/refs/heads/trunk") %}
{%- elif head_branch is containing("refs/heads/main") %}
{%- set_global hash = load_data(path=".git/refs/heads/main") %}
{%- elif head_branch is containing("refs/heads/master") %}
{%- set_global hash = load_data(path=".git/refs/heads/master") %}
{%- endif %}
{%- endif %}

<!DOCTYPE html>
<html lang="{{ config.default_language }}">
Expand Down Expand Up @@ -74,9 +87,7 @@ <h1 class="section-title">{%- block page_title %}{% if page.title %}{{ page.titl
<section class="footer-content">
{% set current_year = now() | date(format="%Y") %}
<footer id="footer-block">
{% if config.extra.footer.copyright == true %}
<p><b>©</b> {{ current_year }} <b>{{ config.author }}</b></p>
{% endif %}
<p>{% if config.extra.footer.hash == true %}{{ hash | truncate(length=7, end="") }} {% endif %}{% if config.extra.footer.copyright == true %}<b>©</b> {{ current_year }} <b>{{ config.author }}</b>{% endif %}</p>
{% if config.extra.footer.stack == true %}
<p>Powered by <a href="https://www.getzola.org" target="_blank">Zola</a> & <a href="https://halve-z.netlify.app" target="_blank">Halve-Z</a></p>
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ links = [
[extra.footer]
enabled = true
copyright = true
hash = false
stack = true

[extra.social]
Expand Down

0 comments on commit ba71c93

Please sign in to comment.