Combined homepage query into 1
This commit is contained in:
@@ -139,9 +139,7 @@
|
|||||||
|
|
||||||
<!-- Time column (only for first day) -->
|
<!-- Time column (only for first day) -->
|
||||||
{#if dayIndex === 0}
|
{#if dayIndex === 0}
|
||||||
<div
|
<div class="border-ecsess-500 bg-ecsess-900 sticky left-0 z-20 border-b-2">
|
||||||
class="border-ecsess-500 bg-ecsess-900 sticky left-0 z-20 border-b-2"
|
|
||||||
>
|
|
||||||
{#each timeSlots as timeSlot}
|
{#each timeSlots as timeSlot}
|
||||||
{@const isHourMark = timeSlot % 60 === 0}
|
{@const isHourMark = timeSlot % 60 === 0}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,36 +1,36 @@
|
|||||||
import { getFromCMS } from '$lib/utils.js';
|
import { getFromCMS } from '$lib/utils.js';
|
||||||
import type { HomepageCMSResponse, OfficeHour, Sponsors } from '$lib/schemas';
|
import type { HomepageCMSResponse, OfficeHour, Sponsors } from '$lib/schemas';
|
||||||
|
|
||||||
const homepageQuery = `*[_type == "homepage"]{
|
const homepageQuery = `{
|
||||||
"description": description[],
|
"homepage": *[_type == "homepage"]{
|
||||||
"councilPhoto": councilPhoto.asset->url+"?h=1200&fm=webp",
|
"councilPhoto": councilPhoto.asset->url+"?h=1200&fm=webp",
|
||||||
"faqs": faqs[]{ question, answer },
|
"faqs": faqs[]{ question, answer },
|
||||||
}[0]`;
|
}[0],
|
||||||
|
"officeHours": *[_type=="officeHours"]{
|
||||||
const ohQuery = `*[_type=="officeHours"]{
|
day,
|
||||||
day,
|
startTime,
|
||||||
startTime,
|
endTime,
|
||||||
endTime,
|
"member": {
|
||||||
"member": {
|
"name": member->name,
|
||||||
"name": member->name,
|
"position": member->position
|
||||||
"position": member->position
|
}
|
||||||
}
|
},
|
||||||
}`;
|
"sponsors": *[_type=="sponsors"]{
|
||||||
|
|
||||||
const sponsorQuery = `*[_type=="sponsors"]{
|
|
||||||
name,
|
name,
|
||||||
url,
|
url,
|
||||||
"logo": logo.asset->url+"?h=100&fm=webp"
|
"logo": logo.asset->url+"?h=100&fm=webp"
|
||||||
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
export const load = async ({ url }) => {
|
export const load = async ({ url }) => {
|
||||||
/**
|
/**
|
||||||
* @description Response data type based on the `homepageQuery` above.
|
* @description Response data type based on the combined query above.
|
||||||
* Note that `description` is a rich/portable text type
|
* Note that `description` is a rich/portable text type
|
||||||
*/
|
*/
|
||||||
let homepageResp: HomepageCMSResponse = await getFromCMS(homepageQuery);
|
let homePageResp = await getFromCMS(homepageQuery);
|
||||||
let officeHourResp: OfficeHour[] = await getFromCMS(ohQuery);
|
let homepageResp: HomepageCMSResponse = homePageResp.homepage;
|
||||||
let sponsorsResp: Sponsors[] = await getFromCMS(sponsorQuery);
|
let officeHourResp: OfficeHour[] = homePageResp.officeHours;
|
||||||
|
let sponsorsResp: Sponsors[] = homePageResp.sponsors;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
description: homepageResp.description,
|
description: homepageResp.description,
|
||||||
|
|||||||
Reference in New Issue
Block a user