{{- $folder := .Get "folder" -}}
{{- $recursive := default false (.Get "recursive") -}}
{{- $take := default 0 (.Get "take") -}}
{{- $tagsParam := .Get "tags" -}}
{{- $tags := slice -}}
{{- if $tagsParam -}}
{{- $tags = split $tagsParam "," -}}
{{- end -}}
{{- $strict := default false (.Get "strict") -}}
{{- $daysShown := int (default 0 (.Get "daysShown")) -}}
{{- $allFiles := slice -}}
{{- $baseURL := $.Site.BaseURL -}}
{{- $commitURLPrefix := add "https://github.com/Azure" .Site.Params.base "/commit/" -}}
{{- $commitsURLPrefix := add "https://github.com/Azure" .Site.Params.base "/commits/main/docs/content/" -}}
{{- if $recursive -}}
{{- $allFiles = partial "readDirRecursive" (dict "path" $folder "allFiles" $allFiles) -}}
{{- else -}}
{{- $entries := readDir $folder -}}
{{- range $entries -}}
{{- $allFiles = $allFiles | append (printf "%s/%s" $folder .Name) -}}
{{- end -}}
{{- end -}}
{{- $specs := slice -}}
{{- range $allFiles -}}
{{- $file := replace . "content/" "" -}}
{{- $page := site.GetPage $file -}}
{{- if $page -}}
{{- $pageTags := $page.Params.tags -}}
{{- $addPageToList := true -}}
{{- if gt (len $tags) 0 -}}
{{- if $strict -}}
{{- if not (eq (len $tags) (len $pageTags)) -}}
{{- $addPageToList = false -}}
{{- else -}}
{{- range $tags -}}
{{- if not (in $pageTags .) -}}
{{- $addPageToList = false -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- range $tags -}}
{{- if not (in $pageTags .) -}}
{{- $addPageToList = false -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $addPageToList -}}
{{- $lastModifiedDate := $page.Params.lastmod -}}
{{ $timeFormat := "2006-01-02 15:04:05" }}
{{- if or (eq $daysShown 0) ($lastModifiedDate.After (now.AddDate 0 0 (int (mul -1 $daysShown ))).UTC) -}}
{{- $titleParts := split $page.Params.title " - " -}}
{{- $id := index $titleParts 0 -}}
{{- $url := $page.Params.url -}}
{{- $commit := $page.GitInfo.AbbreviatedHash -}}
{{- $authorName := $page.GitInfo.AuthorName -}}
{{- $gitHistory := $page.File.Path -}}
{{- $gitHistory = replace $gitHistory `\` `/` -}}
{{- $spec := dict "LastModifiedDate" ($lastModifiedDate.UTC.Format $timeFormat) "ID" $id "URL" (printf "%s%s" $baseURL $url) "GitHistory" $gitHistory "Commit" $commit "AuthorName" $authorName -}}
{{- $specs = $specs | append $spec -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{ if gt (len $specs) 0 }}
{{- $sortedSpecs := sort $specs "LastModifiedDate" "desc" -}}
{{- if gt $take 0 -}}
{{- $sortedSpecs = first $take $sortedSpecs -}}
{{- end -}}
{{ if eq $daysShown 0 }}See specification history...{{ else }}See what specifications changed in the last {{ $daysShown }} days{{ end }}...
{{ if eq $daysShown 0 }}See specification history...{{ else }}See what specifications changed in the last {{ $daysShown }} days{{ end }}...
*/}}
{{- $index := 0 -}}
{{- range $sortedSpecs -}}
{{- $index = add $index 1 -}}
#
ID
Last Modified (UTC)
Git History
Last Commit
{{/* Last Author's Name */}}
{{- end -}}
{{ $index }}
{{ .ID }}
{{ .LastModifiedDate }}
All Commits
{{ .Commit }}
{{/* {{ .AuthorName }} */}}
No specifications were changed in the last {{ $daysShown }} days.
{{ end -}}