baseof.html 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {{- $s := .Site.Params }}
  2. {{- $p := .Params }}
  3. <!DOCTYPE html>
  4. <html lang="{{ .Lang }}" data-figures="{{ $p.figurePositionShow }}"{{ if .IsPage }} class="page"{{ end }}{{ with $s.enforceLightMode }} data-mode="lit"{{ end }}{{ with $s.enforceDarkMode }} data-mode="dim"{{ end }}>
  5. <head>
  6. {{- partial "head" . }}
  7. <!-- styles definition-->
  8. {{- $options := (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") -}}
  9. {{ $mainSassFile := "sass/main.sass" }}
  10. {{- $styles := resources.Get $mainSassFile | resources.ExecuteAsTemplate $mainSassFile . | resources.ToCSS $options }}
  11. {{- if (eq (getenv "HUGO_ENV") "production") -}}
  12. {{- $styles = $styles | minify | fingerprint "sha512" -}}
  13. {{- end -}}
  14. <!-- scripts definition -->
  15. {{- $highlightPath := "js/highlight.js" }}
  16. {{- $highlight := resources.Get $highlightPath | resources.ExecuteAsTemplate $highlightPath . }}
  17. {{- $functionsScriptPath := "js/functions.js" }}
  18. {{- $functions := resources.Get $functionsScriptPath | resources.ExecuteAsTemplate $functionsScriptPath . }}
  19. {{- $codeScriptPath := "js/code.js" }}
  20. {{- $code := resources.Get $codeScriptPath | resources.ExecuteAsTemplate $codeScriptPath . }}
  21. {{- $customScriptPath := "js/custom.js" }}
  22. {{ if (fileExists "../../assets/js/custom.js") }}
  23. {{ $customScriptPath := "../../assets/js/custom.js" }}
  24. {{ end }}
  25. {{- $custom := resources.Get $customScriptPath | resources.ExecuteAsTemplate $customScriptPath . }}
  26. {{- $mainScriptPath := "js/index.js" }}
  27. {{- $main := resources.Get $mainScriptPath | resources.ExecuteAsTemplate $mainScriptPath . }}
  28. {{- $bundle := slice $highlight $functions $code $main $custom | resources.Concat "js/bundle.js" | resources.Minify | resources.Fingerprint "sha512" -}}
  29. <!-- preload assets declaration -->
  30. <link rel="preload" href="{{ $styles.Permalink }}" integrity = "{{ $styles.Data.Integrity }}" as="style" crossorigin="anonymous">
  31. <link rel="preload" href="{{ $bundle.Permalink }}" as="script" integrity=
  32. "{{ $bundle.Data.Integrity }}" crossorigin="anonymous">
  33. <!-- styles file -->
  34. <link rel="stylesheet" type="text/css" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}" crossorigin="anonymous">
  35. {{- with $s.customCSS }}
  36. {{- range . -}}
  37. <link rel="stylesheet" href="{{ relURL . }}">
  38. {{- end }}
  39. {{- end }}
  40. {{ partial "hooks/head-end.html" . }}
  41. </head>
  42. {{- $maxCodeLines := 100 }}
  43. {{- with $s.codeMaxLines }}
  44. {{- $maxCodeLines = . }}
  45. {{- end }}
  46. {{- with $p.codeMaxLines }}
  47. {{- $maxCodeLines = . }}
  48. {{- end }}
  49. {{- $codeLineNumbers := false }}
  50. {{ with $s.codeLineNumbers }}
  51. {{- $codeLineNumbers = . }}
  52. {{ end }}
  53. {{ with $p.codeLineNumbers }}
  54. {{- $codeLineNumbers = . }}
  55. {{ else }}
  56. {{ if eq $p.codeLineNumbers false }}
  57. {{- $codeLineNumbers = false }}
  58. {{ end }}
  59. {{ end }}
  60. <body data-code="{{ $maxCodeLines }}" data-lines="{{ $codeLineNumbers }}" id="documentTop">
  61. {{- partial "header" . }}
  62. <main>
  63. {{- block "main" . }}{{ end }}
  64. </main>
  65. {{- partial "icons" }}
  66. {{- partial "footer" . }}
  67. <script type="text/javascript" src="{{ $bundle.Permalink }}" integrity="{{ $bundle.Data.Integrity }}" crossorigin="anonymous"></script>
  68. {{- with $s.customJS }}
  69. {{- range . -}}
  70. <script type="text/javascript" src="{{ relURL . }}" ></script>
  71. {{- end }}
  72. {{- end }}
  73. {{ partial "hooks/body-end.html" . }}
  74. </body>
  75. </html>