Skip to content

Commit f8664b2

Browse files
committed
Partial: Refactored to be generic
1 parent f850e24 commit f8664b2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

layouts/partials/changelog-date.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
{{ $changelogContent := readFile "content/nginx-one/changelog.md" }}
1+
{{ $productUrl := .Page.Permalink }}
2+
{{ $baseUrl := .Site.BaseURL }}
3+
{{ $linkSplit := split (replace $productUrl $baseUrl "") "/" }}
4+
{{ $productName := index $linkSplit 0 }}
5+
{{ $changelogContent := readFile (printf "content/%s/changelog.md" $productName) }}
26
{{ $maxNumLogs := 3 }}
37
{{ $headings := first $maxNumLogs (findRE `(?m)^##\s(.+)$` $changelogContent) }}
8+
49
<ul>
510
{{ range $headings }}
611
{{ $title := replaceRE "^##\\s" "" . }}
7-
<li><a href="{{ absURL "nginx-one/changelog/" }}#{{urlize $title}}">{{ $title }}</a></li>
12+
<li><a href="{{ absURL (print $productName "/changelog/#" (urlize $title)) }}">{{ $title }}</a></li>
813
{{ end }}
9-
<li><a href="{{ absURL "nginx-one/changelog/" }}">Older...</a></li>
14+
<li><a href="{{ absURL (print $productName "/changelog/")}}">Older...</a></li>
1015
</ul>

0 commit comments

Comments
 (0)