{{- /* recent.html (shortcode): Renders a list of the latest posts. Target: _index.md Example: {{< recent TITLE="" LIMIT="">}} Params: - TITLE (string, optional): H2 heading. - LIMIT (integer, optional): Number of items to show (Default: 4). Error handler: - warnf (To-Do) - OCD (To-Do) To-do: 1. Enable OCD Repo: https://github.com/oxypteros/alpha */ -}} {{- /* Case-insensitive parameter retrieval (default chaining) */}} {{- $title := .Get "TITLE" | default (.Get "Title") | default (.Get "title") }} {{- $limit := .Get "LIMIT" | default (.Get "Limit") | default (.Get "limit") }} {{- /* Validate limit value */}} {{- $isNumber := (printf "%v" $limit | findRE "^[1-9][0-9]*$") }} {{- $intNumber := 4 }} {{- $warnNumber := false }} {{- if $isNumber }} {{- $intNumber = (index $isNumber 0 | int) }} {{- else if $limit }} {{- $warnNumber = true }} {{- end }} {{- /* Shortcode Rendering */}}
{{- /* Optional title rendering. */}} {{- with $title }}

{{ $title }}

{{- end }}
{{- range first $intNumber .Site.RegularPages.ByDate.Reverse }} {{- /* Find the first letter of the title */}} {{- $titleAccent := substr .Title 0 1 }} {{- /* Display only the first category term of the taxonomy */}} {{- $category := "" -}} {{- with .GetTerms "categories" -}} {{- if ge (len .) 1 -}} {{- $category = (index . 0).LinkTitle -}} {{- end -}} {{- end -}} {{- /* Display 'new' badge only if `date` < 7 days from last build */}} {{- $new := gt .Date (now.AddDate 0 0 -7) }}
{{- if $new }} {{- $date := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{- end }}

{{ .Title }}

{{- if or .Page.Params.series $category }}
{{ with .Page.Params.series }} {{ . }} {{- end }}
{{- with $category }} {{ . }} {{- end }}
{{- else }} {{- /* Maintain the card layout if no series/category */}}
{{- end }}
{{- end }}