File tree Expand file tree Collapse file tree
_javascript/modules/layouts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import Swup from 'swup' ;
22import SwupHeadPlugin from '@swup/head-plugin' ;
3- import SwupScriptsPlugin from '@swup/scripts-plugin' ;
3+
4+ let swupInstance = null ;
45
56export function initSwup ( ) {
6- const swup = new Swup ( {
7+ // Prevent multiple instances
8+ if ( swupInstance ) return ;
9+
10+ swupInstance = new Swup ( {
711 containers : [ '#swup' ] ,
812 animationSelector : '.swup-transition-main' ,
913 cache : true ,
14+ animateHistoryBrowsing : true ,
1015 plugins : [
1116 new SwupHeadPlugin ( {
12- persistAssets : true // keep existing CSS/JS, avoid re-downloading
13- } ) ,
14- new SwupScriptsPlugin ( {
15- head : true ,
16- body : true
17+ persistAssets : true
1718 } )
1819 ]
1920 } ) ;
2021
2122 // Update sidebar active state after navigation
22- swup . hooks . on ( 'page:view' , ( ) => {
23+ swupInstance . hooks . on ( 'page:view' , ( ) => {
2324 const currentPath = window . location . pathname ;
2425 const navItems = document . querySelectorAll ( '#sidebar .nav-item' ) ;
2526
Original file line number Diff line number Diff line change 11/* Swup page transition */
22.swup-transition-main {
3+ opacity : 1 ;
34 transition : opacity 0.2s ease-in-out ;
45}
56
67html .is-changing .swup-transition-main {
78 opacity : 0 ;
89}
9-
10- html .is-animating .swup-transition-main {
11- opacity : 1 ;
12- }
You can’t perform that action at this time.
0 commit comments