1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-21 04:41:36 +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

@@ -2,18 +2,18 @@
// IT'S ALL JUST JUNK FOR OUR DOCS!
// ++++++++++++++++++++++++++++++++++++++++++
(function () {
(() => {
'use strict'
var inputElement = document.getElementById('search-input')
const inputElement = document.getElementById('search-input')
if (!window.docsearch || !inputElement) {
return
}
var siteDocsVersion = inputElement.getAttribute('data-bd-docs-version')
const siteDocsVersion = inputElement.getAttribute('data-bd-docs-version')
document.addEventListener('keydown', function (event) {
document.addEventListener('keydown', event => {
if (event.ctrlKey && event.key === '/') {
event.preventDefault()
inputElement.focus()
@@ -25,11 +25,11 @@
indexName: 'bootstrap',
inputSelector: '#search-input',
algoliaOptions: {
facetFilters: ['version:' + siteDocsVersion]
facetFilters: [`version:${siteDocsVersion}`]
},
transformData: function (hits) {
return hits.map(function (hit) {
var liveUrl = 'https://getbootstrap.com/'
transformData(hits) {
return hits.map(hit => {
const liveUrl = 'https://getbootstrap.com/'
hit.url = window.location.origin.startsWith(liveUrl) ?
// On production, return the result as is