Skip to content

Commit 8333d0f

Browse files
authored
Move changelog-date partial to theme from documentation (#290)
* Partial: Move changelog-date to theme from documentation * Partial: Refactored to be generic * Partial: Added default text if no changelog
1 parent de4f0cb commit 8333d0f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

layouts/partials/changelog-date.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- Get the product name -->
2+
{{ $productUrl := .Page.Permalink }}
3+
{{ $baseUrl := .Site.BaseURL }}
4+
{{ $linkSplit := split (replace $productUrl $baseUrl "") "/" }}
5+
{{ $productName := index $linkSplit 0 }}
6+
<!-- Get the content -->
7+
{{ $changelogContent := readFile (printf "content/%s/changelog.md" $productName) }}
8+
{{ $maxNumLogs := 3 }}
9+
{{ $headings := first $maxNumLogs (findRE `(?m)^##\s(.+)$` $changelogContent) }}
10+
11+
<ul>
12+
{{ if gt (len $headings) 0 }}
13+
{{ range $headings }}
14+
{{ $title := replaceRE "^##\\s" "" . }}
15+
<li><a href="{{ absURL (print $productName "/changelog/#" (urlize $title)) }}">{{ $title }}</a></li>
16+
{{ end }}
17+
<li><a href="{{ absURL (print $productName "/changelog/")}}">Older...</a></li>
18+
{{ else }}
19+
<li><p>No changelog found...</p></li>
20+
{{ end }}
21+
</ul>

0 commit comments

Comments
 (0)