Skip to content

Commit

Permalink
Add customCss, customJs support to doc and home page
Browse files Browse the repository at this point in the history
  • Loading branch information
life1347 committed Jan 8, 2024
1 parent e0dbc4e commit ebd922d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions layouts/partials/docs/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
{{- $style = $style | minify | fingerprint "sha384" }}
{{- end -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $style.Data.Integrity }}"{{ end -}} crossorigin="anonymous">
{{ range .Site.Params.docCustomCss -}}
<link rel="stylesheet" href="{{ . | absURL }}"/>
{{- end }}

<!-- Custom JS -->
{{ range .Site.Params.docCustomJs -}}
<script src="{{ . | absURL }}"></script>
{{- end }}

<!-- Katex CSS -->
{{- if .Params.katex -}}
{{- $options := dict "enableSourceMap" true }}
Expand Down
11 changes: 10 additions & 1 deletion layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
{{- $style = $style | minify | fingerprint "sha384" }}
{{- end -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $style.Data.Integrity }}"{{ end -}}/>
{{ range .Site.Params.customCss -}}
<link rel="stylesheet" href="{{ . | absURL }}"/>
{{- end }}
<!-- Bootstrap JS -->
{{ $js := resources.Get "js/bootstrap.js" }}
{{ $params := dict }}
Expand All @@ -35,7 +38,13 @@
{{ if hugo.IsProduction }}
{{ $js = $js | fingerprint "sha384" }}
{{ end }}
<script src="{{ $js.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $js.Data.Integrity }}"{{ end -}} defer></script>
<script src="{{ $js.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $js.Data.Integrity }}"{{ end -}} defer></script>

<!-- Custom JS -->
{{ range .Site.Params.customJs -}}
<script src="{{ . | absURL }}"></script>
{{- end }}

<!-- Image Compare Viewer -->
{{ if ($.Scratch.Get "image_compare_enabled") }}
{{ $imagecompare := resources.Get "js/image-compare-viewer.min.js" }}
Expand Down

0 comments on commit ebd922d

Please sign in to comment.