turbolinks opcional

This commit is contained in:
f 2020-09-15 10:04:18 -03:00
parent 147af78352
commit ae133915c8

View file

@ -1,7 +1,15 @@
--- ---
--- ---
document.addEventListener('{%- if site.turbolinks.enabled -%}turbolinks:load{%- else -%}DOMContentLoaded{%- endif -%}', () => { const loadEvent = () => {
try {
if (Turbolinks) return 'turbolinks:load'
} catch {
return 'DOMContentLoaded'
}
}
document.addEventListener(loadEvent(), () => {
document.querySelectorAll('.share').forEach(share => { document.querySelectorAll('.share').forEach(share => {
share.addEventListener('click', event => { share.addEventListener('click', event => {
if (!Navigator.share) return; if (!Navigator.share) return;