parse_theme.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {{- $scr := .Scratch -}}
  2. {{- $theme_index := (site.Params.theme | lower | replaceRE "\\s" "_") | default "minimal" -}}
  3. {{- $font_index := (index site.Data.themes $theme_index).font_theme | default (site.Params.font | lower | replaceRE "\\s" "_") | default $theme_index | default "minimal" -}}
  4. {{- $font_size := site.Params.font_size | default "m" -}}
  5. {{- $font_sizes := dict "s" 16 "m" 21 "l" 25 -}}
  6. {{- $font_size_numeric := (index $font_sizes $font_size) | default (index $font_sizes "m") -}}
  7. {{- $scr.Set "font_size" $font_size_numeric -}}
  8. {{- $scr.Set "font_size_small" (mul 0.77 $font_size_numeric) -}}
  9. {{/* Attempt to load font style specified by user. */}}
  10. {{ if (index site.Data.fonts $font_index) }}
  11. {{- $font := index site.Data.fonts $font_index -}}
  12. {{- $scr.Set "google_fonts" $font.google_fonts -}}
  13. {{- $scr.Set "body_font" $font.body_font -}}
  14. {{- $scr.Set "heading_font" $font.heading_font -}}
  15. {{- $scr.Set "nav_font" $font.nav_font -}}
  16. {{- $scr.Set "mono_font" $font.mono_font -}}
  17. {{ else }}
  18. {{ errorf "The `%s` font set was not found! Check that the `font` option in `config/_default/params.toml` matches the name of an installed font set." $font_index }}
  19. {{ end }}
  20. {{/* Attempt to load color theme specified by user. */}}
  21. {{ if (index site.Data.themes $theme_index) }}
  22. {{ $theme := index site.Data.themes $theme_index }}
  23. {{- $scr.Set "light" ($theme.light | default true) -}}
  24. {{ if $theme.light }}
  25. {{- $scr.Set "background" ($theme.background | default "#fff") -}}
  26. {{- $scr.Set "dark_background" "rgb(40, 42, 54)" -}}
  27. {{- $scr.Set "home_section_odd" $theme.home_section_odd -}}
  28. {{- $scr.Set "home_section_even" $theme.home_section_even -}}
  29. {{- $scr.Set "dark_home_section_odd" "hsla(231, 15%, 18%, 1)" -}}
  30. {{- $scr.Set "dark_home_section_even" "hsla(231, 15%, 16%, 1)" -}}
  31. {{ else }}
  32. {{- $scr.Set "background" ($theme.background | default "#fff") -}}
  33. {{- $scr.Set "dark_background" ($theme.background | default "rgb(40, 42, 54)") -}}
  34. {{- $scr.Set "home_section_odd" "rgb(255, 255, 255)" -}}
  35. {{- $scr.Set "home_section_even" "rgb(247, 247, 247)" -}}
  36. {{- $scr.Set "dark_home_section_odd" $theme.home_section_odd -}}
  37. {{- $scr.Set "dark_home_section_even" $theme.home_section_even -}}
  38. {{ end }}
  39. {{- $scr.Set "link" ($theme.link | default $theme.primary) -}}
  40. {{- $scr.Set "link_hover" ($theme.link_hover | default $theme.primary) -}}
  41. {{- $scr.Set "primary" $theme.primary -}}
  42. {{- $scr.Set "menu_primary" $theme.menu_primary -}}
  43. {{- $scr.Set "menu_text" $theme.menu_text -}}
  44. {{- $scr.Set "menu_text_active" $theme.menu_text_active -}}
  45. {{- $scr.Set "menu_title" $theme.menu_title -}}
  46. {{ else }}
  47. {{ errorf "The `%s` color theme was not found! Check that the `theme` option in `config/_default/params.toml` matches the name of an installed color theme." $theme_index }}
  48. {{ end }}