Update packages and redirect page

This commit is contained in:
Antoine Phan
2025-09-07 14:32:58 -04:00
parent 7028e2b353
commit 36875ccaf6
5 changed files with 66 additions and 60 deletions

View File

@@ -2,7 +2,7 @@
let { children = () => 'Section placeholder', black = false } = $props();
let tailwindClasses = $state(
'mx-auto flex min-h-[75vh] flex-col items-center justify-center gap-4 p-4 text-center text-ecsess-200'
'mx-auto flex min-h-[90vh] flex-col items-center justify-center gap-4 p-4 text-center text-ecsess-200'
);
if (black) {

View File

@@ -58,4 +58,8 @@ export type Sponsors = {
logo: string;
};
export type Redirect = { shortname: string; url: string };
export type Redirect = {
name: string;
shortname: string;
url: string;
};

View File

@@ -2,14 +2,14 @@ import { redirect } from '@sveltejs/kit';
import { getFromCMS } from '$lib/utils.js';
import type { Redirect } from '$lib/schemas';
const redirectQuery = `*[_type == "redirects"]{ shortname, url }`;
const redirectQuery = `*[_type == "redirects"]{ name, shortname, url }`;
export const load = async ({ params }) => {
let CMSresponse: Redirect[] = await getFromCMS(redirectQuery);
let allRedirects: Redirect[] = await getFromCMS(redirectQuery);
const { shortname } = params;
CMSresponse.forEach((res) => {
allRedirects.forEach((res) => {
if (res.shortname == shortname) {
// if match
throw redirect(302, res.url);
@@ -18,6 +18,6 @@ export const load = async ({ params }) => {
return {
shortname: shortname,
availableShortnames: CMSresponse
availableShortnames: allRedirects
};
};

View File

@@ -1,5 +1,6 @@
<script>
import Section from 'components/Section.svelte';
import Link from 'components/Link.svelte';
let { data } = $props();
</script>
@@ -11,11 +12,12 @@
<div>
Maybe you were trying to get to:
<ul>
{#each data.availableShortnames as s}
<li class="list-disc list-inside">
<a href={s.url}>
/r/{s.shortname}
</a>
{#each data.availableShortnames as redirect}
<li class="list-disc list-inside text-lg my-1">
{redirect.name} ~
<Link href={redirect.url}>
/r/{redirect.shortname}
</Link>
</li>
{/each}
</ul>