{{- /* status-card.html (shortcode): Renders a card with text content provided within the shortcode. Target: Content files. Example: {{< status-card TITLE="" TYPE="" >}} /... Markdown.../ {{< /status-card >}} Params: - TITLE (string, optional): `h2` heading. - TYPE (string, optional): Rendering type ('error'|'warning'|'success'|'info'). Default: 'info'. Error handler: - warnf - OCD Docs: https://alpha.oxypteros.com/shortcodes/status-card Repo: https://github.com/oxypteros/alpha */ -}} {{- /* Case-insensitive parameter retrieval (default chaining) */}} {{- $title := .Get "TITLE" | default (.Get "Title") | default (.Get "title") }} {{- $type := .Get "TYPE" | default (.Get "Type") | default (.Get "type") | default "info" }} {{- /* Allow case-insensitive matching*/}} {{- $type = lower $type }} {{- $content := .Inner | markdownify }} {{- /* Context for error reporting (warnf, OCD) */}} {{ $page := .Page.RelPermalink }} {{- /* OCD: Validate params manually against an allowlist. */}} {{- $allowedKeys := slice "title" "type" }} {{- $invalidKeys := slice }} {{- /* Invalid Parameter Error Handling (OCD) */}} {{- /* NOTE: Not closed shortcode error is handled by Hugo */}} {{- range $key, $value := .Params }} {{- if not (in $allowedKeys (lower $key)) }} {{- $invalidKeys = $invalidKeys | append $key }} {{- end }} {{- end }} {{- if gt (len $invalidKeys) 0 }} {{- /* Warnf for error: ocd-sc-131 */}} {{- $errorCode := "ocd-sc-131" }} {{- $invalidKeysString := delimit $invalidKeys ", " }} {{- $errorMessage := printf "Invalid parameters: %s" $invalidKeysString }} {{- $logMessage := printf "OcdError [%s] Page: %s | %s" $errorCode $page $errorMessage }} {{- warnf "%s" $logMessage }} {{- /* OCD error card for: odc-sc-131 */}} {{- if and (eq hugo.Environment "development") (hugo.IsServer) (eq .Page.Site.Params.ocd_enabled true) }}
{{- i18n "OcdScParamError" . | default "Shortcode Parameter Error" }}

{{- $count := len $invalidKeys }} {{- i18n "OcdScStatusCard131" $count | default "Invalid parameter in the status-card shortcode on this page:" }} {{ .Page.Title }}

{{- i18n "OcdScParameter" $count | default "The parameters," }}  {{ $invalidKeysString }}  {{ i18n "OcdScNotRecognized" $count | default "are not recognized." }}


{{ i18n "OcdScAcceptedParameters" . | default "Accepted parameters:" }} TITLE, TYPE

{{- end }} {{- end }} {{- /* Shortcode Rendering */}} {{- if eq $type "error" }}
{{- with $title }}

{{ $title }}

{{- end }}
{{ $content }}
{{- else if eq $type "warning" }}
{{- with $title }}

{{ $title }}

{{- end }}
{{ $content }}
{{- else if eq $type "success" }}
{{- with $title }}

{{ $title }}

{{- end }}
{{ $content }}
{{- else if eq $type "info" }}
{{- with $title }}

{{ $title }}

{{- end }}
{{ $content }}
{{- else }} {{- /* Warnf for error: ocd-sc-130 */}} {{- $errorCode := "ocd-sc-130" }} {{- $errorMessage := printf "Wrong TYPE input - %s" $type }} {{- $logMessage := printf "OcdError [%s] Page: %s | %s)" $errorCode $page $errorMessage }} {{- warnf "%s" $logMessage }} {{- /* OCD error card for: odc-sc-130 */}} {{- if and (eq hugo.Environment "development") (hugo.IsServer) (eq .Page.Site.Params.ocd_enabled true) }}
{{- i18n "OcdScInputError" . |default "Shortcode Input Error" }}

{{- i18n "OcdScStatusCard130" . | default "Invalid type value in the status card shortcode, on:" }} {{ .Page.Title }}

{{- i18n "OcdScSpecifiedType" . | default "The specified type," }} TYPE="{{ $type }}" {{ i18n "OcdScNotRecognized" . | default "is not recognized" }}


{{ i18n "OcdScAvailableTypes" . | default "Available Types:" }} error, warning, success, info

{{- end }} {{- end }}