{{- /* cta.html (shortcode): Renders a Call To Action element with a button styled link. Target: _index.md files. Example: {{< cta TITLE="" BTN-TEXT="" BTN-LINK="" BTN-LABEL="">}} Params: - TITLE (string, optional): H2 heading. - BTN-TEXT (string, optional): link text for link 1 (button styled) - BTN-LINK (string, optional): href attribute for link 1 - BTN-LABEL (string, optional): aria-label attribute for link 1 Error handler: - warnf - OCD Docs: https://alpha.oxypteros.com/docs/shortcodes/cta Repo: https://github.com/oxypteros/alpha */ -}} {{- /* Case-insensitive parameter retrieval (default chaining) */}} {{- $title := .Get "TITLE" | default (.Get "Title") | default (.Get "title") }} {{- $btnLink := .Get "BTN-LINK" | default (.Get "Btn-Link") | default (.Get "btn-link") }} {{- $btnTxt := .Get "BTN-TEXT" | default (.Get "Btn-Title") | default (.Get "btn-title")}} {{- $btnAria := .Get "BTN-LABEL" | default (.Get "Btn-Label") | default (.Get "btn-label") }} {{- $content := .Inner | markdownify }} {{- /* Context for error reporting (warnf, OCD)*/}} {{ $page := .Page.RelPermalink }} {{- /* warnf, OCD: Validate params manually against an allowlist. */}} {{- $allowedKeys := slice "title" "btn-link" "btn-text" "btn-label" }} {{- $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-141 */}} {{- $errorCode := "ocd-sc-141" }} {{- $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-141 */}} {{- if and (eq hugo.Environment "development") (hugo.IsServer) (eq .Page.Site.Params.ocd_enabled true) }}
{{- $count := len $invalidKeys }} {{- i18n "OcdScCta141" $count | default "Invalid parameter detected in the status card shortcode, on:" }} {{ .Page.Title }}
{{- i18n "OcdScParameter" $count | default "The parameters," }} {{ $invalidKeysString }} {{ i18n "OcdScNotRecognized" $count | default "are not recognized." }}
{{ i18n "OcdScAcceptedParameters" . | default "Accepted parameters:" }} TITLE, BTN-TEXT, BTN-LINK, BTN-LABEL,
{{- i18n "OcdScCta142" . | default "Missing link text in the cta shortcode on:" }} {{ .Page.Title }}
{{- i18n "OcdScTheParameter" . | default "The parameter" }} BTN-TEXT {{ i18n "OcdScLinkNotRendered" . | default "is missing, so the link will not be rendered." }}
{{- i18n "OcdScFillParameter" . | default "Provide a value for the parameter" }} BTN-TEXT="Your Button Text" {{ i18n "OcdScOrDeleteParameter" . | default "or delete the" }} BTN-LINK="{{ $btnLink }}"