{{- /* about.html (shortcode): Renders an about element with username and avatar. Target Pages: Global Example: {{< about AUTHOR="" AVATAR="">}} Params: - AUTHOR (string, optional): H2 heading. Fall back to frontmatter author - AVATAR (string, optional): Avatar filename placed inside /assets/img/ Error handler: - warnf - OCD Docs: https://alpha.oxypteros.com/docs/shortcodes/about Repo: https://github.com/oxypteros/alpha */ -}} {{- /* Case-insensitive parameter retrieval (default chaining) */}} {{- $author := .Get "AUTHOR" | default (.Get "Author") | default (.Get "author") | default .Page.Params.author }} {{- $avatar := .Get "AVATAR" | default (.Get "Avatar") | default (.Get "avatar") }} {{- $content := .Inner | markdownify }} {{- /* Context for error reporting (warnf, OCD) */}} {{ $page := .Page.RelPermalink }} {{- /* warnf, OCD: Validate params manually against an allowlist. */}} {{- $allowedKeys := slice "author" "avatar" }} {{- $invalidKeys := slice }} {{- /* Invalid Parameter Error Handling (warnf, OCD) */}} {{- 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-161 */}} {{- $errorCode := "ocd-sc-161" }} {{- $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-161 */}} {{- 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 "OcdScAbout161" $count | default "Invalid parameter in the about shortcode on:" }} {{ .Page.Title }}

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


{{ i18n "OcdScAcceptedParameters" . | default "Accepted parameters:" }} AUTHOR, AVATAR

{{- end }} {{- end }} {{- /* Image validation */}} {{- $path := printf "/img/%s" $avatar }} {{- $image := "" }} {{- if $avatar }} {{- $image = resources.Get $path }} {{- end }} {{- $warnImg := false }} {{- if and $avatar ( eq $image nil) }} {{- $warnImg = true }} {{- end }} {{- if $warnImg }} {{- /* Warnf for error: ocd-sc-162 */}} {{- $errorCode := "ocd-sc-162" }} {{- $errorMessage := printf "Image not found: %s (/assets/img/)" $avatar }} {{- $logMessage := printf "OcdError [%s] - Page: %s | %s" $errorCode $page $errorMessage }} {{- warnf "%s" $logMessage }} {{- /* OCD error card for: odc-sc-162 */}} {{- if and (eq hugo.Environment "development") (hugo.IsServer) (eq .Page.Site.Params.ocd_enabled true) }}
{{- i18n "OcdScContentError" . | default "Shortcode Content Error" }}

{{- i18n "OcdScAbout162" . | default "Missing image for shortcode about on:" }} {{ .Page.Title }}

{{- i18n "OcdScTheParameter" . | default "The parameter" }}  AVATAR  {{ i18n "OcdScIsSetButTheFile" . | default "is set, but the file" }} {{ $avatar }}  {{ i18n "OcdScWasNotFound" . | default "was not found." }}


{{- i18n "OcdScValidValue" . | default "Provide a valid value for the parameter" }} AVATAR {{ i18n "OcdScOrEnsureThat" . | default "or ensure that" }} {{ $avatar }} {{ i18n "OcdScExistsAt" . | default "exists at" }} /assets/img/{{ $avatar }}

{{- end }} {{- end }} {{- /* Shortcode Rendering */}}
{{- if and $avatar $image }} {{- $webp := $image.Resize "100x100 webp" }} {{- $webp2x := $image.Resize "200x200 webp" }} {{ i18n {{- end }}
{{ $author }}
{{ $content }}