-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Description
We recently added an Ancestor
method, but I suspect most people will want to render the full history, or the last N changes, requiring a recursive partial similar to:
{{ partial "inline/changelog.html" .GitInfo }}
{{ define "_partials/inline/changelog.html" }}
{{ with . }}
{{ partial "inline/changelog.html" .Ancestor }}
{{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}<br>
{{ end }}
{{ end }}
Conceptually this new method would align with the .Page.Ancestors
method that is commonly used when rendering a breadcrumbs UI component.
{{ with .GitInfo }}
{{ range .Ancestors }}
{{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}
{{ end }}
{{ end }}
OR
{{ with .GitInfo }}
{{ range .Ancestors | first 5 }}
{{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}
{{ end }}
{{ end }}
The above would give you the last 5 changes.
If this is practical from a performance standpoint (and it may not be), and we implement an Ancestors
method, it seems like the Ancestor
method (singular) could be removed.