mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
40 lines
2.5 KiB
HTML
40 lines
2.5 KiB
HTML
{{- /* Code header for classic mode code blocks */ -}}
|
|
{{- $config := .Config -}}
|
|
{{- $wrapper := .Wrapper -}}
|
|
{{- $lang := cond (transform.CanHighlight .Type) (lower .Type) "fallback" -}}
|
|
{{- $name := $config.name -}}
|
|
{{- $lineNosBtn := "" -}}
|
|
{{- $lineWrapBtn := "" -}}
|
|
{{- $editBtn := "" -}}
|
|
{{- $copyBtn := "" -}}
|
|
{{- $foldIcon := dict "Class" "arrow fa-solid fa-chevron-down fa-fw" | partial "plugin/icon.html" -}}
|
|
{{- $titleEl := printf `<span class="code-title">%s</span>` $foldIcon -}}
|
|
{{- $ellipsisBtn := printf `<span class="ellipses-btn" aria-label="Show more options" role="button">%s</span>` (dict "Class" "fa-solid fa-ellipsis-h fa-fw" | partial "plugin/icon.html") -}}
|
|
|
|
{{- if $config.title -}}
|
|
{{- $titleEl = printf `<span class="code-title">%s<span class="title-inner">%s</span></span>` $foldIcon $config.title -}}
|
|
{{- end -}}
|
|
{{- if $config.linenostoggler -}}
|
|
{{- $lineNosIcon := dict "Class" "fa-solid fa-list-ol fa-fw" | partial "plugin/icon.html" -}}
|
|
{{- $lineNosBtn = printf `<span class="line-nos-btn" aria-label="%s" role="button" title="%s">%s</span>` (T "assets.toggleLineNumbers") (T "assets.toggleLineNumbers") $lineNosIcon -}}
|
|
{{- end -}}
|
|
{{- if $config.linewraptoggler -}}
|
|
{{- $lineWrapIcon := dict "Class" "fa-solid fa-right-left fa-fw" | partial "plugin/icon.html" -}}
|
|
{{- $lineWrapBtn = printf `<span class="line-wrap-btn" aria-label="%s" role="button" title="%s">%s</span>` (T "assets.toggleLineWrap") (T "assets.toggleLineWrap") $lineWrapIcon -}}
|
|
{{- end -}}
|
|
{{- if $config.editable -}}
|
|
{{- $editIcon := dict "Class" "fa-solid fa-pen-to-square fa-fw" | partial "plugin/icon.html" -}}
|
|
{{- $editBtn = printf `<span class="edit-btn" aria-label="%s" role="button" title="%s">%s</span>` (T "assets.toggleCodeEditable") (T "assets.toggleCodeEditable") $editIcon -}}
|
|
{{- end -}}
|
|
{{- if $config.copyable -}}
|
|
{{- $copyIcon := dict "Class" "fa-regular fa-clone fa-fw" | partial "plugin/icon.html" -}}
|
|
{{- $copyBtn = printf `<span class="copy-btn" aria-label="%s" role="button" title="%s">%s</span>` (T "assets.copyToClipboard") (T "assets.copyToClipboard") $copyIcon -}}
|
|
{{- end -}}
|
|
{{- with $config.name -}}
|
|
{{- $titleEl = replace $titleEl `<span class="code-title">` (printf `<span class="code-title" data-name="%s">` .) -}}
|
|
{{- end -}}
|
|
{{- $codeHeader := printf `<div class="code-header language-%s">%s%s%s%s%s%s</div>` $lang $titleEl $ellipsisBtn $lineNosBtn $lineWrapBtn $editBtn $copyBtn -}}
|
|
{{- $wrapper = replaceRE `(<div class="code-wrapper">)` (printf "%s$1" $codeHeader) $wrapper -}}
|
|
|
|
{{- return $wrapper -}}
|