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:
@@ -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' })
|
||||
}
|
||||
|
Reference in New Issue
Block a user