File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
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 @@ -4,12 +4,12 @@ import Layout from "@layouts/SectionLayout.astro";
4
4
import SponsorCard from " @components/SponsorCard.astro" ;
5
5
import Headline from " @ui/Headline.astro" ;
6
6
7
- const sponsors = await getCollection (" sponsors" , ({ data }) => {
7
+ const sponsors = ( await getCollection (" sponsors" , ({ data }) => {
8
8
const isProd = import .meta .env .MODE === " production" ;
9
9
const notDraft = ! isProd || data .draft !== true ;
10
10
const isPartner = data .tier === " Partners" ;
11
11
return notDraft && isPartner ;
12
- });
12
+ })). sort (( a , b ) => a . id . localeCompare ( b . id )) ;
13
13
14
14
---
15
15
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export async function getStaticPaths() {
21
21
const sessions = await getCollection (" sessions" );
22
22
23
23
const { entry } = Astro .props ;
24
-
24
+ const slug = entry . id ;
25
25
const speakers = await getEntries (entry .data .speakers );
26
26
27
27
// Resolve session codes to session data
@@ -233,3 +233,12 @@ const nextSessionsOrdered = sameRoomNextSession
233
233
</footer >
234
234
</Section >
235
235
</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