File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ import { getCollection } from " astro:content" ;
3+ export async function getStaticPaths() {
4+ const sessions = await getCollection (" sessions" );
5+ return sessions .map ((entry ) => ({
6+ params: { code: entry .data .code },
7+ props: { slug: entry .id },
8+ }));
9+ }
10+ const { slug } = Astro .props ;
11+ return Astro .rewrite (` /session/${slug } ` );
12+ ---
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,12 @@ const nextSessionsOrdered = sameRoomNextSession
233233 </footer >
234234 </Section >
235235</Layout >
236+
237+ <script is:inline define:vars ={ { slug }} >
238+ const currentUrl = window.location.pathname;
239+ const expectedUrl = `/session/${slug}`;
240+
241+ if (currentUrl !== expectedUrl) {
242+ window.history.replaceState({}, '', expectedUrl);
243+ }
244+ </script >
You can’t perform that action at this time.
0 commit comments