14 lines
448 B
HTML
14 lines
448 B
HTML
{{/*
|
|||
|
|
This helper is used to generate a background color and text color from a string
|
||
|
|
Used to generate deterministic colors for tags, categories, etc.
|
||
|
|
*/}}
|
||
|
|
|
||
|
|
{{- $str := . -}}
|
||
|
|
{{- $hash := hash.FNV32a $str -}}
|
||
|
|
{{- $h := mod $hash 360 -}}
|
||
|
|
|
||
|
|
{{- $backgroundColor := printf "hsl(%d, 60%%, 84%%)" $h -}}
|
||
|
|
{{- $textColor := printf "hsl(%d, 60%%, 15%%)" $h -}}
|
||
|
|
|
||
|
|
{{- return dict "BackgroundColor" $backgroundColor "TextColor" $textColor "Hue" $h -}}
|