From 79509ea264725eea45e048a2233aef06c5c06148 Mon Sep 17 00:00:00 2001 From: "louismaxime.piton" Date: Fri, 25 Aug 2023 15:42:49 +0200 Subject: [PATCH] Provide the color mode button in every Stackblitz example --- site/layouts/partials/scripts.html | 65 ++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/site/layouts/partials/scripts.html b/site/layouts/partials/scripts.html index dc92d30e5ac9..3ed9f8ad4242 100644 --- a/site/layouts/partials/scripts.html +++ b/site/layouts/partials/scripts.html @@ -38,7 +38,7 @@ StackBlitzSDK.openBootstrapSnippet = (htmlSnippet, jsSnippet, classes) => { const markup = ` - + @@ -46,24 +46,81 @@ Bootstrap Example <${'script'} src="{{ .Site.Params.cdn.js_bundle }}"> + <${'script'} src="https://getbootstrap.com/docs/{{ .Site.Params.docs_version }}/assets/js/color-modes.js"> ${htmlSnippet.replace(/^/gm, ' ')} + + + + + + + + + + + + + + + + + + + + + + ` - const jsSnippetContent = jsSnippet ? '{{ os.ReadFile "site/assets/js/snippets.js" }}' : null + const colorModeSnippet = '{{ os.ReadFile "site/static/docs/5.3/assets/js/color-modes.js" }}' + const jsSnippetContent = jsSnippet ? '{{ os.ReadFile "site/assets/js/snippets.js" }}' + colorModeSnippet : colorModeSnippet const project = { files: { 'index.html': markup, - 'index.js': jsSnippetContent + 'index.js': jsSnippetContent.replace(/}\)\(\).*\(\(\) => {.*'use strict'/gms, '').replace(/window.add.*\(\) => {([\s\S]*)}\)([\s\S]}\)\(\))/gm, '$1 $2') }, title: 'Bootstrap Example', description: `Official example from ${window.location.href}`, - template: jsSnippet ? 'javascript' : 'html', + template: 'javascript', tags: ['bootstrap'] }