File tree Expand file tree Collapse file tree
docs-src/src/content/docs/guides Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,11 +50,11 @@ with:
5050``` html
5151<script
5252 type =" module"
53- src =" https://cdn.jsdelivr.net/npm/shepherd.js@15 .0.0/dist/js/shepherd.mjs"
53+ src =" https://cdn.jsdelivr.net/npm/shepherd.js@17 .0.0/dist/js/shepherd.mjs"
5454></script >
5555<link
5656 rel =" stylesheet"
57- href =" https://cdn.jsdelivr.net/npm/shepherd.js@15 .0.0/dist/css/shepherd.css"
57+ href =" https://cdn.jsdelivr.net/npm/shepherd.js@17 .0.0/dist/css/shepherd.css"
5858/>
5959```
6060
Original file line number Diff line number Diff line change @@ -162,3 +162,34 @@ const { isHome } = Astro.props;
162162 }
163163 </div >
164164</header >
165+
166+ <script >
167+ // Handle demo button click - redirect to home if not already there
168+ function setupDemoButton() {
169+ const showTourBtn = document.querySelector('#showTour');
170+
171+ if (!showTourBtn) return;
172+
173+ // Remove any existing listeners
174+ const newBtn = showTourBtn.cloneNode(true) as HTMLElement;
175+ showTourBtn.parentNode?.replaceChild(newBtn, showTourBtn);
176+
177+ newBtn.addEventListener('click', () => {
178+ // Check if we're on the home page
179+ if (window.location.pathname !== '/') {
180+ // Store flag to start tour after navigation
181+ sessionStorage.setItem('startTourOnLoad', 'true');
182+ window.location.href = '/';
183+ } else {
184+ // We're already on home page, dispatch event to start tour
185+ window.dispatchEvent(new CustomEvent('startTour'));
186+ }
187+ });
188+ }
189+
190+ // Run on initial load
191+ document.addEventListener('DOMContentLoaded', setupDemoButton);
192+
193+ // Run on Astro page transitions
194+ document.addEventListener('astro:page-load', setupDemoButton);
195+ </script >
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import MainPage from '@layouts/MainPage.astro';
2424 <Code
2525 code ={ `
2626 <link rel="stylesheet" href="shepherd.js/dist/css/shepherd.css"/>
27- <script type="module" src="shepherd.js/dist/shepherd.mjs"></script>
27+ <script type="module" src="shepherd.js/dist/js/ shepherd.mjs"></script>
2828
2929` }
3030 lang =" js"
@@ -94,9 +94,16 @@ import MainPage from '@layouts/MainPage.astro';
9494 // wait for shepherd to be ready
9595 setTimeout(function () {
9696 const shepherd = setupShepherd();
97- const startBtn = document.querySelector('#showTour');
98-
99- startBtn?.addEventListener('click', () => shepherd.start());
97+
98+ // Check if we should auto-start the tour (after redirect from another page)
99+ const shouldStartTour = sessionStorage.getItem('startTourOnLoad');
100+ if (shouldStartTour) {
101+ sessionStorage.removeItem('startTourOnLoad');
102+ shepherd.start();
103+ }
104+
105+ // Listen for custom event from Demo button when already on home page
106+ window.addEventListener('startTour', () => shepherd.start());
100107 }, 400);
101108 }
102109
@@ -297,6 +304,8 @@ import MainPage from '@layouts/MainPage.astro';
297304
298305 function ready() {
299306 document.addEventListener('DOMContentLoaded', init);
307+ // Also listen for Astro page transitions
308+ document.addEventListener('astro:page-load', init);
300309 }
301310
302311 ready();
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ <h3>Example</h3>
122122
123123 <!-- Shepherd -->
124124 < script type ="module ">
125- import Shepherd from '../dist/esm /shepherd.mjs' ;
125+ import Shepherd from '../dist/js /shepherd.mjs' ;
126126
127127 window . Shepherd = Shepherd ;
128128
Original file line number Diff line number Diff line change 1818 " Robbie Wagner <rwwagner90@gmail.com>" ,
1919 " Chuck Carpenter <chuck@shipshape.io>"
2020 ],
21- "main" : " ./dist/cjs/shepherd.cjs " ,
21+ "main" : " ./dist/cjs/shepherd.mjs " ,
2222 "module" : " ./dist/js/shepherd.mjs" ,
2323 "exports" : {
2424 "." : {
You can’t perform that action at this time.
0 commit comments