diff --git a/app/app/javascript/application.js b/app/app/javascript/application.js index c275ea8..e239947 100644 --- a/app/app/javascript/application.js +++ b/app/app/javascript/application.js @@ -1,2 +1,3 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "controllers" +import "@hotwired/turbo-rails" diff --git a/app/app/javascript/controllers/admin_list_controller.js b/app/app/javascript/controllers/admin_list_controller.js index 7eed176..358e064 100644 --- a/app/app/javascript/controllers/admin_list_controller.js +++ b/app/app/javascript/controllers/admin_list_controller.js @@ -6,6 +6,6 @@ export default class extends Controller { const href = event.currentTarget.dataset.href - window.location.href = href + Turbo.visit(href) } } diff --git a/app/app/views/layouts/admin/application.html.haml b/app/app/views/layouts/admin/application.html.haml index 27535ab..c134a40 100644 --- a/app/app/views/layouts/admin/application.html.haml +++ b/app/app/views/layouts/admin/application.html.haml @@ -9,6 +9,8 @@ = csp_meta_tag = stylesheet_link_tag 'admin', 'data-turbo-track': 'reload' = javascript_importmap_tags + %meta{ name: 'turbo-prefetch', content: 'true' } + %meta{ name: 'view-transition', content: 'same-origin' } %body - if logged_in? .application diff --git a/app/app/views/layouts/media/application.html.haml b/app/app/views/layouts/media/application.html.haml index d17e492..2708ebb 100644 --- a/app/app/views/layouts/media/application.html.haml +++ b/app/app/views/layouts/media/application.html.haml @@ -8,6 +8,9 @@ = csp_meta_tag %link{ rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/yakuhanjp@4.0.1/dist/css/yakuhanjp.css' } = stylesheet_link_tag 'media', 'data-turbo-track': 'reload' + = javascript_importmap_tags + %meta{ name: 'turbo-prefetch', content: 'true' } + %meta{ name: 'view-transition', content: 'same-origin' } %body .application .application__header diff --git a/app/config/importmap.rb b/app/config/importmap.rb index 9cbf71f..98698b8 100644 --- a/app/config/importmap.rb +++ b/app/config/importmap.rb @@ -6,3 +6,4 @@ pin '@hotwired/stimulus', to: 'stimulus.min.js', preload: true pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js', preload: true pin_all_from 'app/javascript/controllers', under: 'controllers' +pin '@hotwired/turbo-rails', to: 'turbo.min.js'