diff options
| author | XhmikosR <[email protected]> | 2022-12-18 23:32:17 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-18 14:32:17 -0700 |
| commit | e1315d11f2fb9a43b96dd48bf8f9aaf5305372b2 (patch) | |
| tree | a1f09437ae0d47979c6e157e8dffcd1867a0ca82 /site | |
| parent | 6807008159012b9cf370db87dcd804c4cae3a1b5 (diff) | |
| download | bootstrap-e1315d11f2fb9a43b96dd48bf8f9aaf5305372b2.tar.xz bootstrap-e1315d11f2fb9a43b96dd48bf8f9aaf5305372b2.zip | |
docs: move color-mode script (#37658)
* docs: move color-mode script
* Move color-modes.js in static folder
* Async load color-modes.js
* Switch to DOMContentLoaded
* Revert async loading
Diffstat (limited to 'site')
| -rw-r--r-- | site/content/docs/5.2/customize/color-modes.md | 2 | ||||
| -rw-r--r-- | site/layouts/partials/header.html | 6 | ||||
| -rw-r--r-- | site/static/docs/5.2/assets/js/color-modes.js (renamed from site/assets/js/color-modes/index.js) | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/site/content/docs/5.2/customize/color-modes.md b/site/content/docs/5.2/customize/color-modes.md index 929075cbb..bf1692ae1 100644 --- a/site/content/docs/5.2/customize/color-modes.md +++ b/site/content/docs/5.2/customize/color-modes.md @@ -248,7 +248,7 @@ Here's a look at the JavaScript that powers it. Feel free to inspect our own doc {{< example lang="js" show_preview="false" >}} {{< js.inline >}} -{{- readFile (path.Join "site/assets/js/color-modes/index.js") -}} +{{- readFile (path.Join "site/static/docs" .Site.Params.docs_version "assets/js/color-modes.js") -}} {{< /js.inline >}} {{< /example >}} diff --git a/site/layouts/partials/header.html b/site/layouts/partials/header.html index 327ed1488..22528ae47 100644 --- a/site/layouts/partials/header.html +++ b/site/layouts/partials/header.html @@ -1,6 +1,3 @@ -{{- $colorModeJS := resources.Get "js/color-modes/index.js" }} -<script src="{{ $colorModeJS.Permalink | relURL }}"></script> - <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="{{ .Page.Params.description | default .Site.Params.description | markdownify }}"> @@ -22,6 +19,9 @@ <meta name="robots" content="{{ . }}"> {{- end }} +{{- $colorModeJS := printf "/docs/%s/assets/js/color-modes.js" $.Site.Params.docs_version -}} +<script src="{{ $colorModeJS | relURL }}"></script> + {{ partial "stylesheet" . }} {{ partial "favicons" . }} {{ partial "social" . }} diff --git a/site/assets/js/color-modes/index.js b/site/static/docs/5.2/assets/js/color-modes.js index 51bfd40a7..41b6b893e 100644 --- a/site/assets/js/color-modes/index.js +++ b/site/static/docs/5.2/assets/js/color-modes.js @@ -46,7 +46,7 @@ } }) - window.addEventListener('load', () => { + window.addEventListener('DOMContentLoaded', () => { showActiveTheme(getPreferredTheme()) document.querySelectorAll('[data-bs-theme-value]') |
