diff --git a/site/assets/js/stackblitz.js b/site/assets/js/stackblitz.js index c6f44b0f4f27..8e41c87b117e 100644 --- a/site/assets/js/stackblitz.js +++ b/site/assets/js/stackblitz.js @@ -28,12 +28,12 @@ document.querySelectorAll('.btn-edit').forEach(btn => { // Get extra classes for this example const classes = Array.from(exampleEl.classList).join(' ') - sdk.openBootstrapSnippet(htmlSnippet, jsSnippet, classes) + openBootstrapSnippet(htmlSnippet, jsSnippet, classes) }) }) -sdk.openBootstrapSnippet = (htmlSnippet, jsSnippet, classes) => { - const markup = ` +const openBootstrapSnippet = (htmlSnippet, jsSnippet, classes) => { + const html = ` @@ -45,17 +45,17 @@ sdk.openBootstrapSnippet = (htmlSnippet, jsSnippet, classes) => { - -${htmlSnippet.replace(/^/gm, ' ')} - + +${htmlSnippet.trimStart().replace(/^/gm, ' ').replace(/^ {4}$/gm, '').trimEnd()} + -` + +` - const jsSnippetContent = jsSnippet ? jsSnippetFile : null const project = { files: { - 'index.html': markup, - 'index.js': jsSnippetContent + 'index.html': html, + ...(jsSnippet && { 'index.js': jsSnippetFile }) }, title: 'Bootstrap Example', description: `Official example from ${window.location.href}`,