diff options
author | Tiger Oakes <contact@tigeroakes.com> | 2022-04-12 18:07:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 18:07:25 +0300 |
commit | fe257823ecca31cf5e582e9b8380a0ad0204075e (patch) | |
tree | 1ebe321ce3bd30686cbd49a58272d8845d07a673 /site/layouts/partials/scripts.html | |
parent | f6cb4b64b57f751df4563fe80e0f4eb4c19fb8e4 (diff) |
Use Babel and ES6 in docs JS files (#31607)
* Pass docs js through Babel
* Use ES6 in docs js
* Only run babel on src files
* Allow babel in Hugo
* Update scripts.html
* Inherit from the root .eslintrc.json
* Use `Array.from`
* Drop Babel from docs
* Prefer template
* replace IIFE with arrow functions
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Co-authored-by: GeoSot <geo.sotis@gmail.com>
Diffstat (limited to 'site/layouts/partials/scripts.html')
-rw-r--r-- | site/layouts/partials/scripts.html | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/site/layouts/partials/scripts.html b/site/layouts/partials/scripts.html index 47cc55dff7..2b70521f5d 100644 --- a/site/layouts/partials/scripts.html +++ b/site/layouts/partials/scripts.html @@ -23,19 +23,16 @@ {{ if eq .Page.Layout "docs" -}} <script> // Open in StackBlitz logic - document.querySelectorAll('.btn-edit') - .forEach(function (btn) { - btn.addEventListener('click', function (event) { - var htmlSnippet = event.target.closest('.bd-edit').previousSibling.innerHTML + document.querySelectorAll('.btn-edit').forEach(btn => { + btn.addEventListener('click', event => { + const htmlSnippet = event.target.closest('.bd-edit').previousSibling.innerHTML - StackBlitzSDK.openBootstrapSnippet(htmlSnippet) - }) + StackBlitzSDK.openBootstrapSnippet(htmlSnippet) }) + }) - StackBlitzSDK.openBootstrapSnippet = function(snippet) { - var project = { - files: { - 'index.html': `<!doctype html> + StackBlitzSDK.openBootstrapSnippet = snippet => { + const markup = `<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> @@ -52,12 +49,16 @@ ${snippet.replace(/^/gm, ' ')} <${'script'} src="{{ .Site.Params.cdn.js_bundle }}"></${'script'}> </body> </html>` - }, - title: 'Bootstrap Example', - description: 'Official example from ' + window.location.href, - template: 'html', - tags: ['bootstrap'] - } + + const project = { + files: { + 'index.html': markup + }, + title: 'Bootstrap Example', + description: `Official example from ${window.location.href}`, + template: 'html', + tags: ['bootstrap'] + } StackBlitzSDK.openProject(project, { openFile: 'index.html' }) } |