File tree 4 files changed +40
-6
lines changed
docs/content/en/methods/page
4 files changed +40
-6
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,22 @@ This is configurable. See [details].
123
123
{{ end }}
124
124
```
125
125
126
+ ###### Ancestor
127
+
128
+ (` *source.GitInfo ` ) The file-filtered ancestor commit, if any.
129
+
130
+ ``` go-html-template
131
+ {{ partial "inline/changelog.html" .GitInfo }} → 2023-10-09: Add tutorials
132
+ 2025-03-26: Edit GitInfo docs
133
+
134
+ {{ define "_partials/inline/changelog.html" }}
135
+ {{ with . }}
136
+ {{ partial "inline/changelog.html" .Ancestor }}
137
+ {{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}<br>
138
+ {{ end }}
139
+ {{ end }}
140
+ ```
141
+
126
142
## Last modified date
127
143
128
144
By default, when ` enableGitInfo ` is ` true ` , the ` Lastmod ` method on a ` Page ` object returns the Git AuthorDate of the last commit that included the file.
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ require (
8
8
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.44.10
9
9
github.com/bep/clocks v0.5.0
10
10
github.com/bep/debounce v1.2.0
11
- github.com/bep/gitmap v1.6 .0
11
+ github.com/bep/gitmap v1.7 .0
12
12
github.com/bep/goat v0.5.0
13
13
github.com/bep/godartsass/v2 v2.5.0
14
14
github.com/bep/golibsass v1.2.0
Original file line number Diff line number Diff line change @@ -125,8 +125,8 @@ github.com/bep/clocks v0.5.0 h1:hhvKVGLPQWRVsBP/UB7ErrHYIO42gINVbvqxvYTPVps=
125
125
github.com/bep/clocks v0.5.0 /go.mod h1:SUq3q+OOq41y2lRQqH5fsOoxN8GbxSiT6jvoVVLCVhU =
126
126
github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo =
127
127
github.com/bep/debounce v1.2.0 /go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0 =
128
- github.com/bep/gitmap v1.6 .0 h1:sDuQMm9HoTL0LtlrfxjbjgAg2wHQd4nkMup2FInYzhA =
129
- github.com/bep/gitmap v1.6 .0 /go.mod h1:n+3W1f/rot2hynsqEGxGMErPRgT41n9CkGuzPvz9cIw =
128
+ github.com/bep/gitmap v1.7 .0 h1:jvPnRQv5RG6IDPrwoDiwAhTE/DmdEkOW4poFeUYmjI8 =
129
+ github.com/bep/gitmap v1.7 .0 /go.mod h1:n+3W1f/rot2hynsqEGxGMErPRgT41n9CkGuzPvz9cIw =
130
130
github.com/bep/goat v0.5.0 h1:S8jLXHCVy/EHIoCY+btKkmcxcXFd34a0Q63/0D4TKeA =
131
131
github.com/bep/goat v0.5.0 /go.mod h1:Md9x7gRxiWKs85yHlVTvHQw9rg86Bm+Y4SuYE8CTH7c =
132
132
github.com/bep/godartsass/v2 v2.5.0 h1:tKRvwVdyjCIr48qgtLa4gHEdtRkPF8H1OeEhJAEv7xg =
Original file line number Diff line number Diff line change @@ -155,7 +155,23 @@ func NewFileInfo(fi hugofs.FileMetaInfo) *File {
155
155
}
156
156
157
157
func NewGitInfo (info gitmap.GitInfo ) GitInfo {
158
- return GitInfo (info )
158
+ gi := GitInfo {
159
+ Hash : info .Hash ,
160
+ AbbreviatedHash : info .AbbreviatedHash ,
161
+ Subject : info .Subject ,
162
+ AuthorName : info .AuthorName ,
163
+ AuthorEmail : info .AuthorEmail ,
164
+ AuthorDate : info .AuthorDate ,
165
+ CommitDate : info .CommitDate ,
166
+ Body : info .Body ,
167
+ }
168
+
169
+ if info .Ancestor != nil {
170
+ anc := NewGitInfo (* info .Ancestor )
171
+ gi .Ancestor = & anc
172
+ }
173
+
174
+ return gi
159
175
}
160
176
161
177
// GitInfo provides information about a version controlled source file.
@@ -176,10 +192,12 @@ type GitInfo struct {
176
192
CommitDate time.Time `json:"commitDate"`
177
193
// The commit message's body.
178
194
Body string `json:"body"`
195
+ // The file-filtered ancestor commit, if any.
196
+ Ancestor * GitInfo `json:"ancestor"`
179
197
}
180
198
181
199
// IsZero returns true if the GitInfo is empty,
182
200
// meaning it will also be falsy in the Go templates.
183
- func (g GitInfo ) IsZero () bool {
184
- return g .Hash == ""
201
+ func (g * GitInfo ) IsZero () bool {
202
+ return g == nil || g .Hash == ""
185
203
}
You can’t perform that action at this time.
0 commit comments