1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-26 14:54:27 +02:00

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>
This commit is contained in:
Tiger Oakes
2022-04-12 08:07:25 -07:00
committed by GitHub
parent f6cb4b64b5
commit fe257823ec
11 changed files with 122 additions and 167 deletions

View File

@@ -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' })
}