GROQ query optimization
This commit is contained in:
@@ -4,25 +4,26 @@ import { getFromCMS } from '$lib/utils.js';
|
|||||||
// Note: council member image has height of 200px for
|
// Note: council member image has height of 200px for
|
||||||
// CouncilCard: image is `size-32` ~ 128px
|
// CouncilCard: image is `size-32` ~ 128px
|
||||||
// CouncilCardPopUp: image is `size-42` ~ 168px
|
// CouncilCardPopUp: image is `size-42` ~ 168px
|
||||||
const councilQuery = `*[_type == "members"]{
|
const councilQuery = `{
|
||||||
name,
|
"members": *[_type == "members"]{
|
||||||
email,
|
name,
|
||||||
position,
|
email,
|
||||||
positionDescription,
|
position,
|
||||||
"image": image.asset->url+"?h=300&fm=webp",
|
positionDescription,
|
||||||
yearProgram
|
"image": image.asset->url+"?h=300&fm=webp",
|
||||||
|
yearProgram
|
||||||
|
},
|
||||||
|
"councilGoofyPic": *[_type == "homepage"]{
|
||||||
|
"url": councilGoofyPic.asset->url+"?h=1200&fm=webp"
|
||||||
|
}[0]
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
const councilGoofyPicQuery = `*[_type == "homepage"]{
|
|
||||||
"url": councilGoofyPic.asset->url+"?h=1200&fm=webp"
|
|
||||||
}[0]`;
|
|
||||||
|
|
||||||
export const load = async ({ url }) => {
|
export const load = async ({ url }) => {
|
||||||
let councilMembers: CouncilMember[] = await getFromCMS(councilQuery);
|
const { members, councilGoofyPic }: { members: CouncilMember[], councilGoofyPic: { url: string } } = await getFromCMS(councilQuery);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
members: councilMembers,
|
members: members,
|
||||||
councilGoofyPic: await getFromCMS(councilGoofyPicQuery),
|
councilGoofyPic,
|
||||||
canonical: url.href
|
canonical: url.href
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user