head.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <head>
  2. {{ partial "meta" . }}
  3. <link
  4. rel="stylesheet"
  5. href="https://use.fontawesome.com/releases/v5.15.2/css/all.css"
  6. integrity="sha384-vSIIfh2YWi9wW0r9iZe7RJPrKwp6bG+s9QZMoITbCckVJqGCCRhc+ccxNcdpHuYu"
  7. crossorigin="anonymous"
  8. />
  9. <link
  10. rel="stylesheet"
  11. href="https://cdn.rawgit.com/jpswalsh/academicons/master/css/academicons.min.css"
  12. />
  13. <link
  14. rel="stylesheet"
  15. href="//fonts.googleapis.com/css?family=Didact+Gothic%7CRoboto:400%7CRoboto+Mono"
  16. />
  17. {{ $css := resources.Get "main.css" | postCSS }}
  18. {{ if hugo.IsProduction }}
  19. {{ $css = $css | minify | fingerprint | resources.PostProcess }}
  20. {{ end }}
  21. <link href="{{ $css.RelPermalink }}" rel="stylesheet" />
  22. <script>
  23. let html = document.querySelector("html");
  24. let theme = window.localStorage.getItem("theme");
  25. if (theme) {
  26. theme === "dark"
  27. ? html.classList.add("dark")
  28. : html.classList.remove("dark");
  29. } else if (html.classList.contains("dark")) {
  30. window.localStorage.setItem("theme", "dark");
  31. } else {
  32. html.classList.remove("dark");
  33. window.localStorage.setItem("theme", "light");
  34. }
  35. window.onload = () => {
  36. let themeToggle = document.querySelector(".theme-toggle");
  37. if (window.localStorage.getItem("theme") === "dark") {
  38. themeToggle.classList.remove("bi-moon-fill");
  39. themeToggle.classList.add("bi-brightness-high");
  40. } else {
  41. themeToggle.classList.add("bi-moon-fill");
  42. themeToggle.classList.remove("bi-brightness-high");
  43. }
  44. let defaultActivePanel = document.querySelector(".accordion.active");
  45. if (defaultActivePanel) {
  46. defaultActivePanel.nextElementSibling.style.maxHeight =
  47. defaultActivePanel.nextElementSibling.scrollHeight + "px";
  48. }
  49. };
  50. window.onresize = () => {
  51. let defaultActivePanel = document.querySelector(".accordion.active");
  52. if (defaultActivePanel) {
  53. defaultActivePanel.nextElementSibling.style.maxHeight =
  54. defaultActivePanel.nextElementSibling.scrollHeight + "px";
  55. }
  56. };
  57. </script>
  58. </head>