File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 11---
22import { getCollection } from " astro:content" ;
3-
43export async function getStaticPaths() {
54 const sessions = await getCollection (" sessions" );
65 return sessions .map ((entry ) => ({
76 params: { code: entry .data .code },
87 props: { slug: entry .id },
98 }));
109}
11-
1210const { slug } = Astro .props ;
1311return Astro .rewrite (` /session/${slug } ` );
1412---
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export async function getStaticPaths() {
2121const sessions = await getCollection (" sessions" );
2222
2323const { entry } = Astro .props ;
24-
24+ const slug = entry . id ;
2525const speakers = await getEntries (entry .data .speakers );
2626
2727// Resolve session codes to session data
@@ -233,3 +233,16 @@ const nextSessionsOrdered = sameRoomNextSession
233233 </footer >
234234 </Section >
235235</Layout >
236+
237+ <script is:inline define:vars ={ { slug }} >
238+ // Check if the current URL contains the entry ID
239+ const currentUrl = window.location.pathname;
240+ const expectedUrl = `/session/${slug}`;
241+
242+ // If the URL doesn't match the expected URL with the entry ID, replace it
243+ if (currentUrl !== expectedUrl) {
244+ // Use history.replaceState to update the URL without refreshing the page
245+ window.history.replaceState({}, '', expectedUrl);
246+ console.log(`URL updated to match entry ID: ${expectedUrl}`);
247+ }
248+ </script >
You can’t perform that action at this time.
0 commit comments