Skip to content

Commit 755ac1f

Browse files
committed
improve: Move git info to post footer
This is done to give the article heading higher priority than git info. * Remove git info for list and home page as these are rarely updated. * Make post footer printable except for pagination and comments. * If git info is not set in configuration then don't add link to abbreviated hash and commit message subject.
1 parent 946b10c commit 755ac1f

File tree

7 files changed

+48
-31
lines changed

7 files changed

+48
-31
lines changed

assets/styles/_header.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414
}
1515

1616
.gitinfo {
17+
margin: $spacer-normal 0;
18+
border-top: $spacer-1 solid;
19+
1720
@include themed {
1821
color: t($text-duller);
22+
border-color: t($accent);
1923
}
2024

2125
@media print {

assets/styles/_pagination.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
.pagination {
22
margin: $spacer-largest 0;
33

4+
@media print {
5+
display: none;
6+
}
7+
48
&-title {
59
display: flex;
610
text-align: center;

assets/styles/_post.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@
117117
}
118118

119119
&-footer {
120-
@media print {
121-
display: none;
122-
}
123120
margin: $spacer-largest 0;
124121
}
125122

layouts/_default/baseof.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131

3232
{{- /* site main */}}
3333
<main class="site-main">
34-
{{- if .GitInfo -}}
35-
{{- partial "gitinfo.html" . -}}
36-
{{- end -}}
37-
3834
{{- block "main" . -}}
3935
{{ if .Title -}}
4036
<h1 class="post-title">{{ .Title | plainify }}</h1>

layouts/_default/single.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@ <h2>{{ "Table of Contents" | markdownify }}</h2>
5050
</div>
5151
{{- end }}
5252

53-
{{- if eq .Type "posts" }}
54-
<footer class="post-footer">
53+
54+
<footer class="post-footer">
55+
{{- if .GitInfo -}}
56+
{{- partial "gitinfo.html" . -}}
57+
{{- end -}}
58+
59+
{{- if eq .Type "posts" }}
5560
{{- if templates.Exists "partials/support-me.html" -}}
5661
{{- partial "support-me.html" . -}}
5762
{{- end -}}
5863
{{- partial "pagination.html" . -}}
5964
{{- partial "comments.html" . -}}
60-
</footer>
61-
{{- end }}
65+
{{- end }}
66+
</footer>
6267
</article>
6368
{{- end -}}

layouts/partials/footer.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414
<span> from commit: </span>
1515

1616
{{- /* code */}}
17-
<code class="gitinfo">
18-
<a href="{{ $commitUrl }}">
17+
<code>
18+
{{- if eq $commitUrl "" }}
1919
#{{ .short_hash }} |
2020
{{ .subject }}
21-
</a>
21+
{{- else }}
22+
<a href="{{ $commitUrl }}">
23+
#{{ .short_hash }} |
24+
{{ .subject }}
25+
</a>
26+
{{- end }}
2227
</code>
2328
{{- end -}}
2429
{{/* gitinfo */}}
@@ -57,7 +62,10 @@
5762
{{- $git_repo := site.Params.git_info.repo -}}
5863
{{ $gitRepoUrl = printf "https://%s.com/%s/%s" $git_host $git_user $git_repo }}
5964
{{- end -}}
60-
<li><a href="{{ $gitRepoUrl }}">Source</a></li>
65+
66+
{{- if not (eq $gitRepoUrl "") }}
67+
<li><a href="{{ $gitRepoUrl }}">Source</a></li>
68+
{{- end }}
6169
</ul>
6270
</nav>
6371
</div>

layouts/partials/gitinfo.html

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{{- $pageName := "Page" -}}
2-
{{- if .IsHome -}}
3-
{{- $pageName = "Home page" -}}
4-
{{- else if .IsSection -}}
5-
{{- $pageName = print .Title " list" | plainify -}}
6-
{{- else if eq .Type "posts" -}}
2+
{{- if eq .Type "posts" -}}
73
{{- $pageName = print "Article" | plainify -}}
84
{{- else -}}
95
{{- with .File -}}
@@ -23,16 +19,23 @@
2319
{{- end -}}
2420

2521
{{- /* gitinfo */}}
26-
<p class="gitinfo">
27-
{{- /* page name */}}
28-
{{ $pageName }} last updated on {{ .AuthorDate }} by commit
29-
{{- /* code */}}
30-
<code class="gitinfo">
31-
<a href="{{ $commitUrl }}">
32-
#{{ .AbbreviatedHash }} |
33-
{{ .Subject }}
34-
</a>
35-
</code>
36-
</p>
22+
<div class="gitinfo">
23+
<p>
24+
{{- /* page name */}}
25+
{{ $pageName }} last updated on {{ .AuthorDate }} by commit
26+
{{- /* code */}}
27+
<code>
28+
{{- if eq $commitUrl "" }}
29+
#{{ .AbbreviatedHash }} |
30+
{{ .Subject }}
31+
{{- else }}
32+
<a href="{{ $commitUrl }}">
33+
#{{ .AbbreviatedHash }} |
34+
{{ .Subject }}
35+
</a>
36+
{{- end }}
37+
</code>
38+
</p>
39+
</div>
3740
{{- end -}}
3841
{{/* gitinfo */}}

0 commit comments

Comments
 (0)