parse_theme.css 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {{- $scr := .Scratch -}}
  2. {{- $site := $scr.Get "site" -}}
  3. {{/* Attempt to load font style specified by user. */}}
  4. {{- $font_index := site.Params.font | default "default" -}}
  5. {{ if isset site.Data.fonts $font_index }}
  6. {{- $font := index site.Data.fonts $font_index -}}
  7. {{- $scr.Set "google_fonts" $font.google_fonts -}}
  8. {{- $scr.Set "body_font" $font.body_font -}}
  9. {{- $scr.Set "heading_font" $font.heading_font -}}
  10. {{- $scr.Set "nav_font" $font.nav_font -}}
  11. {{- $scr.Set "mono_font" $font.mono_font -}}
  12. {{- $scr.Set "font_size" $font.font_size -}}
  13. {{- $scr.Set "font_size_small" $font.font_size_small -}}
  14. {{ end }}
  15. {{/* Attempt to load color theme specified by user. */}}
  16. {{- $theme_index := site.Params.color_theme | default "default" -}}
  17. {{ if isset site.Data.themes $theme_index }}
  18. {{ $theme := index site.Data.themes $theme_index }}
  19. {{- $scr.Set "light" $theme.light -}}
  20. {{ if and $theme.background $theme.light }}
  21. {{- $scr.Set "background" $theme.background -}}
  22. {{ else }}
  23. {{- $scr.Set "background" "#fff" -}}
  24. {{ end }}
  25. {{ if and $theme.background (not $theme.light) }}
  26. {{- $scr.Set "dark_background" $theme.background -}}
  27. {{ else }}
  28. {{- $scr.Set "dark_background" "rgb(40, 42, 54)" -}}
  29. {{ end }}
  30. {{ if $theme.light }}
  31. {{- $scr.Set "home_section_odd" $theme.home_section_odd -}}
  32. {{- $scr.Set "home_section_even" $theme.home_section_even -}}
  33. {{ else }}
  34. {{- $scr.Set "home_section_odd" "rgb(255, 255, 255)" -}}
  35. {{- $scr.Set "home_section_even" "rgb(247, 247, 247)" -}}
  36. {{ end }}
  37. {{ if not $theme.light }}
  38. {{- $scr.Set "dark_home_section_odd" $theme.home_section_odd -}}
  39. {{- $scr.Set "dark_home_section_even" $theme.home_section_even -}}
  40. {{ else }}
  41. {{- $scr.Set "dark_home_section_odd" "hsla(231, 15%, 18%, 1)" -}}
  42. {{- $scr.Set "dark_home_section_even" "hsla(231, 15%, 16%, 1)" -}}
  43. {{ end }}
  44. {{ if $theme.link }}
  45. {{- $scr.Set "link" $theme.link -}}
  46. {{ else }}
  47. {{- $scr.Set "link" $theme.primary -}}
  48. {{ end }}
  49. {{ if $theme.link_hover }}
  50. {{- $scr.Set "link_hover" $theme.link_hover -}}
  51. {{ else }}
  52. {{- $scr.Set "link_hover" $theme.primary -}}
  53. {{ end }}
  54. {{- $scr.Set "primary" $theme.primary -}}
  55. {{- $scr.Set "primary_light" $theme.primary_light -}}
  56. {{- $scr.Set "primary_dark" $theme.primary_dark -}}
  57. {{- $scr.Set "menu_primary" $theme.menu_primary -}}
  58. {{- $scr.Set "menu_text" $theme.menu_text -}}
  59. {{- $scr.Set "menu_text_active" $theme.menu_text_active -}}
  60. {{- $scr.Set "menu_title" $theme.menu_title -}}
  61. {{ end }}