{{- /* 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) }}
{{- $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
{{- 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 }}