Skip to content

Commit 8395fcc

Browse files
committed
fix: Remove gitinfo data & make it config
1 parent 8b1589e commit 8395fcc

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
googleAnalytics = "G-FX00ZBCNBW"
2+
enableGitInfo = true
3+
4+
[params.git_info]
5+
host = "github"
6+
user = "manid2"
7+
repo = "hugo-xterm"

layouts/partials/footer.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
{{- $gitRepoUrl := "https://github.com/manid2/hugo-xterm/" -}}
2-
31
{{- /* site build info */}}
42
<p class="buildinfo">
53
{{- /* site build timestamp */}}
64
<time datetime="{{ now.Format "2006-01-02 15:04:05 IST" }}">Site built on: {{ now.Format "2006-01-02 15:04:05 IST" }}</time>
75

86
{{- with site.Params.git.last_commit -}}
9-
{{- $commitUrl := printf "https://%s.com/%s/%s/-/commit/%s" site.Data.gitinfo.host site.Data.gitinfo.user site.Data.gitinfo.repo .hash }}
7+
{{- $commitUrl := "" -}}
8+
{{- if (isset site.Params "git_info") -}}
9+
{{- $git_host := site.Params.git_info.host -}}
10+
{{- $git_user := site.Params.git_info.user -}}
11+
{{- $git_repo := site.Params.git_info.repo -}}
12+
{{ $commitUrl = printf "https://%s.com/%s/%s/-/commit/%s" $git_host $git_user $git_repo .hash }}
13+
{{- end -}}
1014
<span> from commit: </span>
1115

1216
{{- /* code */}}
@@ -46,6 +50,13 @@
4650
<ul class="navbar__list">
4751
<li><a href="/posts/index.xml">RSS</a></li>
4852
<li><span>&nbsp;~~&nbsp;</span><a href="/sitemap.xml">Sitemap</a></li>
53+
{{- $gitRepoUrl := "" -}}
54+
{{- if (isset site.Params "git_info") -}}
55+
{{- $git_host := site.Params.git_info.host -}}
56+
{{- $git_user := site.Params.git_info.user -}}
57+
{{- $git_repo := site.Params.git_info.repo -}}
58+
{{ $gitRepoUrl = printf "https://%s.com/%s/%s" $git_host $git_user $git_repo }}
59+
{{- end -}}
4960
<li><span>&nbsp;~~&nbsp;</span><a href="{{ $gitRepoUrl }}">Source</a></li>
5061
</ul>
5162
</nav>

layouts/partials/gitinfo.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
{{- end -}}
1515

1616
{{- with .GitInfo -}}
17-
{{ $commitUrl := printf "https://%s.com/%s/%s/-/commit/%s" site.Data.gitinfo.host site.Data.gitinfo.user site.Data.gitinfo.repo .Hash }}
17+
{{- $commitUrl := "" -}}
18+
{{- if (isset site.Params "git_info") -}}
19+
{{- $git_host := site.Params.git_info.host -}}
20+
{{- $git_user := site.Params.git_info.user -}}
21+
{{- $git_repo := site.Params.git_info.repo -}}
22+
{{ $commitUrl = printf "https://%s.com/%s/%s/-/commit/%s" $git_host $git_user $git_repo .Hash }}
23+
{{- end -}}
1824

1925
{{- /* gitinfo */}}
2026
<p class="gitinfo">

0 commit comments

Comments
 (0)