diff --git a/src/lib/public/links/links.json b/src/lib/public/links/links.json index 260d4652..e18e3ccc 100644 --- a/src/lib/public/links/links.json +++ b/src/lib/public/links/links.json @@ -120,5 +120,9 @@ "stack-visu": "https://stack-visu.vercel.app/", "ui-design": "https://www.figma.com/file/B2RNOWZtitLLmPhQ0NUwdH/Crating-User-Interfaces?type=whiteboard&node-id=0%3A1&t=vqt1hqht1lByr3Ib-1", "ai-art-resources": "https://docs.google.com/document/d/1c8RKbDTg2LcC9DwOXvaY0OXZ61yOQzCIU7TJVDhM0VQ/edit?usp=sharing", - "oss-meeting-3": "https://docs.google.com/presentation/d/1UJOF2p_c9pGvztpB0QiJfLbAMRBkgKLIy_eZPwH6U30/edit?usp=sharing" + "oss-meeting-3": "https://docs.google.com/presentation/d/1UJOF2p_c9pGvztpB0QiJfLbAMRBkgKLIy_eZPwH6U30/edit?usp=sharing", + "oss-meeting-4": "https://docs.google.com/presentation/d/1upCG_6nzI_G5HdK5qKfMvKj61_8qpj1iwOlcIbfvkUo/edit?usp=sharing", + "ai-flowers": "https://docs.google.com/document/d/17aG-MHWo2FO5Hhbnvz_gg5rJWbKPYhfvs9G-4UgBC6U/edit?usp=sharing", + "asset-workshop": "https://docs.google.com/presentation/d/1bFThk1bTUOJ7W8Gqcx0x5zVRuZ6G9rLIx9yewUKXFb4/edit?usp=sharing", + "design2code": "https://www.figma.com/file/47njZNOfMF5lDPSHiG4kJF/Design2Code?type=whiteboard&node-id=0%3A1&t=8SNCeouHjk2sa9mt-1" } diff --git a/src/routes/(site)/6/lucky.svelte b/src/routes/(site)/6/lucky.svelte index e69de29b..4f0bd365 100644 --- a/src/routes/(site)/6/lucky.svelte +++ b/src/routes/(site)/6/lucky.svelte @@ -0,0 +1,45 @@ + + +
+
+
+

I'm feeling lucky!

+
+ +
+
+ + Chip the Capybara surrounded by all ACM Team badges +
+
+ + diff --git a/src/routes/(site)/random/+server.ts b/src/routes/(site)/random/+server.ts new file mode 100644 index 00000000..1cbf0f5f --- /dev/null +++ b/src/routes/(site)/random/+server.ts @@ -0,0 +1,40 @@ +import type { RequestEvent } from '@sveltejs/kit'; + +/** + * The server-side load function for https://acmcsuf.com/random. + */ +export async function GET({ url }: RequestEvent) { + const modules = Object.keys( + await import.meta.glob('../**/+page.svelte', { eager: true, as: 'raw' }) + ); + const pages = getPages(modules); + const randomPage = pages[~~(Math.random() * pages.length)]; + const destination = new URL(randomPage, url); + console.log({ modules, pages }); + return Response.redirect(destination, 302); +} + +/** + * getPages gets the SvelteKit pages given a list of module names. + * + * Reference: + * - https://github.com/sveltejs/kit/issues/923#issuecomment-1567052262 + */ +function getPages(modules: string[]): string[] { + return modules.map(toPathname).filter((pathname) => pathname !== null) as string[]; +} + +function toPathname(input: string): string | null { + // Removes dynamic pages that cannot be dynamically retrieved at random. + // Check for [ and ] symbols in the input string and return null if found + if (input.includes('[') || input.includes(']')) { + return null; + } + + // Deconstruct the pathname parts. + const parts = input.split('/').filter((part) => !!part && part !== '.' && part !== '..'); + + // Reconstruct the pathname while ignoring last part. + const pathname = parts.slice(0, parts.length - 1).join('/'); + return `/${pathname}`; +} diff --git a/static/assets/png/capy-lucky.png b/static/assets/png/capy-lucky.png new file mode 100644 index 00000000..9f6c78a9 Binary files /dev/null and b/static/assets/png/capy-lucky.png differ