sutty-base-jekyll-theme/_packs/entry.js

73 lines
2.1 KiB
JavaScript
Raw Normal View History

import BotDetector from 'device-detector-js/dist/parsers/bot'
2021-01-12 17:14:14 +00:00
import { Notifier } from '@airbrake/browser'
window.bot_detector = new BotDetector
const bot = window.bot_detector.parse(navigator.userAgent)
2021-01-12 17:14:14 +00:00
if (!bot) {
window.airbrake = new Notifier({
projectId: window.env.AIRBRAKE_PROJECT_ID,
projectKey: window.env.AIRBRAKE_PROJECT_KEY,
host: 'https://panel.sutty.nl'
})
console.originalError = console.error
console.error = (...e) => {
window.airbrake.notify(e.join(' '))
return console.originalError(...e)
}
}
2021-01-12 17:14:14 +00:00
2021-01-12 16:35:23 +00:00
import 'core-js/stable'
import 'regenerator-runtime/runtime'
// Turbo acelera la navegación al no tener que recargar todo el JS y CSS
// de la página, con lo que se siente más rápida y "nativa".
//
// Cambiamos de turbolinks a turbo porque turbo soporta la función
// fetch(), que luego es interceptada por el SW para obtener las
// direcciones localmente.
import * as Turbo from "@hotwired/turbo"
Turbo.start()
2021-01-12 16:38:32 +00:00
2020-11-12 16:28:24 +00:00
import { Application } from 'stimulus'
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("./controllers", true, /\.js$/)
application.load(definitionsFromContext(context))
2021-01-12 16:38:32 +00:00
2021-06-01 21:33:49 +00:00
import { makeClient } from '@spree/storefront-api-v2-sdk'
import { Sutty } from './endpoints/sutty'
window.spree = makeClient({ host: window.env.SPREE_URL })
window.spree.sutty = new Sutty(window.spree.host)
try {
window.axe = require('axe-core/axe')
} catch(e) {}
if (window.axe) window.axe.configure({ locale: require('axe-core/locales/es.json') })
2021-09-17 18:41:37 +00:00
document.addEventListener('turbo:load', event => {
2021-09-17 18:42:57 +00:00
document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => {
a.rel = "noopener"
a.target = "_blank"
})
if (!window.axe) return
window.axe.run().then(results => {
results.violations.forEach(violation => {
violation.nodes.forEach(node => {
node.target.forEach(target => {
document.querySelectorAll(target).forEach(element => {
element.classList.add('inaccesible')
element.ariaLabel = node.failureSummary
})
})
})
})
})
2021-01-12 16:38:32 +00:00
})