From 50c07509d9c5f32f9a3421243303c4b871b17f35 Mon Sep 17 00:00:00 2001 From: Antoine Phan Date: Sat, 19 Jul 2025 16:36:00 -0400 Subject: [PATCH] Schemas update + Image optimization Resolves: https://github.com/mcgill-ecsess/ECSESS/issues/20 --- src/lib/schemas.ts | 5 +++++ src/routes/+page.server.ts | 2 +- src/routes/council/+page.server.ts | 15 ++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/lib/schemas.ts b/src/lib/schemas.ts index 605e69a..3c177c6 100644 --- a/src/lib/schemas.ts +++ b/src/lib/schemas.ts @@ -11,6 +11,11 @@ export type EventPost = { payment: string; // event payment link (e.g., Zeffy) }; +export type FAQ = { + question: string; + answer: string; +} + import type { InputValue } from '@portabletext/svelte'; export type HomepageCMSResponse = { diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index e7f4a6d..1b00b9a 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -3,7 +3,7 @@ import type { HomepageCMSResponse, OhCMSResponse } from '$lib/schemas'; const homepageQuery = `*[_type == "homepage"]{ "description": description[], - "councilPhoto": councilPhoto.asset->url, + "councilPhoto": councilPhoto.asset->url+"?h=1200&fm=webp", "faqs": faqs[]{ question, answer }, }[0]`; diff --git a/src/routes/council/+page.server.ts b/src/routes/council/+page.server.ts index d4a5936..ede79b8 100644 --- a/src/routes/council/+page.server.ts +++ b/src/routes/council/+page.server.ts @@ -1,21 +1,26 @@ +import type { CouncilMember } from '$lib/schemas'; import { getFromCMS } from '$lib/utils.js'; -const query = `*[_type == "members"]{ +// Note: council member image has height of 200px for +// CouncilCard: image is `size-32` ~ 128px +// CouncilCardPopUp: image is `size-42` ~ 168px +const councilQuery = `*[_type == "members"]{ name, email, position, positionDescription, - "image": image.asset->url, + "image": image.asset->url+"?h=200&fm=webp", yearProgram }`; const councilGoofyPicQuery = `*[_type == "homepage"]{ - "url": councilGoofyPic.asset->url+"?h=1000&fm=webp" + "url": councilGoofyPic.asset->url+"?h=1200&fm=webp" }[0]`; export const load = async () => { + let councilMembers: CouncilMember[] = await getFromCMS(councilQuery); return { - members: await getFromCMS(query), - councilGoofyPic: await getFromCMS(councilGoofyPicQuery), + members: councilMembers, + councilGoofyPic: await getFromCMS(councilGoofyPicQuery) }; };