From ae133915c865b686fcb7071e1cd2c8c580cb3b8c Mon Sep 17 00:00:00 2001 From: f Date: Tue, 15 Sep 2020 10:04:18 -0300 Subject: [PATCH] turbolinks opcional --- assets/js/script.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/js/script.js b/assets/js/script.js index c3600aa..bf5f470 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -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 => { share.addEventListener('click', event => { if (!Navigator.share) return;