mirror of
https://gitee.com/butubb8/blowfish.git
synced 2025-12-05 14:17:50 +08:00
This in most cases will reduce the size of main.bundle.css dramatically. Before I had around ~+32kB, now it is ~+228B
21 lines
649 B
HTML
21 lines
649 B
HTML
{{ $repoColors := site.Data.repoColors }}
|
|
{{ $classNameMap := dict }}
|
|
{{ range $language, $unused := $repoColors }}
|
|
{{ $className := printf "background-color-%s" (md5 $language) }}
|
|
{{ $classNameMap = merge $classNameMap (dict $className $language) }}
|
|
{{ end }}
|
|
|
|
{{ $classNames := slice }}
|
|
{{ range site.Pages }}
|
|
{{ $matchedClasses := findRE `background-color-[a-f0-9]{32}` .Content }}
|
|
{{ range $matchedClasses }}
|
|
{{ with index $classNameMap . }}
|
|
{{ $classNames = $classNames | append . }}
|
|
{{ else }}
|
|
{{ $classNames = $classNames | append "fallback" }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ return (uniq $classNames) }}
|