CMS fetching, Main page & members page (#12)
* CMS fetching on main page * Getting council members * Image loading for council member * Placeholder avatar
This commit is contained in:
BIN
src/assets/placeholderAvatar.png
Normal file
BIN
src/assets/placeholderAvatar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,31 @@
|
||||
<script>
|
||||
/**
|
||||
* Schemas for Council Members:
|
||||
* {
|
||||
* email,
|
||||
* name,
|
||||
* position,
|
||||
* positionDescription,
|
||||
* yearProgram,
|
||||
* image // CDN URL from Sanity CMS
|
||||
* }
|
||||
*/
|
||||
let { name, position, email, positionDescription, yearProgram, image } = $props();
|
||||
import placeholder from 'assets/placeholderAvatar.png';
|
||||
import { Avatar } from '@skeletonlabs/skeleton-svelte';
|
||||
</script>
|
||||
|
||||
<div class="card h-1/2 max-h-1/2 w-full max-w-1/6 rounded-lg border-4 p-4">
|
||||
<!-- <img class="size-4/5" src={placeholder} alt="Placeholder"> -->
|
||||
<!-- <Avatar src={placeholder} {name} /> -->
|
||||
{#if image}
|
||||
<Avatar src={image} {name} />
|
||||
{:else}
|
||||
<Avatar src={placeholder} {name} />
|
||||
{/if}
|
||||
<p class="pb-2 text-xl font-bold">{name} - <span class="text-sm"> {yearProgram} </span></p>
|
||||
<hr />
|
||||
<p class="py-2 text-base font-bold">~ {position} ~</p>
|
||||
<p class="underline">{email}</p>
|
||||
<p class="text-sm">{positionDescription}</p>
|
||||
</div>
|
||||
|
||||
10
src/routes/+page.server.js
Normal file
10
src/routes/+page.server.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { getFromCMS } from 'utils/utils.js';
|
||||
|
||||
// needs to concat and format this text
|
||||
const query = `*[_type == "homepage"].description[].children[].text`;
|
||||
|
||||
export const load = async () => {
|
||||
return {
|
||||
description: await getFromCMS(query)
|
||||
};
|
||||
};
|
||||
@@ -1,15 +1,7 @@
|
||||
<script>
|
||||
import Section from 'components/Section.svelte';
|
||||
|
||||
// Getting info from ECSESS CMS
|
||||
// let description =
|
||||
// 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
|
||||
const query = '_type:homepage';
|
||||
|
||||
let description = $state();
|
||||
description = fetch(
|
||||
`https://${import.meta.env.SANITY_ID}.api.sanity.io/vX/data/query/production?query=${query}&perspective=drafts`
|
||||
).then((res) => res.json).then((json) => json.toString());
|
||||
/** loading things from the server side */
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<title> McGill ECSESS </title>
|
||||
@@ -18,8 +10,7 @@
|
||||
<Section>
|
||||
<div class="flex h-1/2 flex-col items-center justify-center text-center">
|
||||
<p class="page-title">What is ECSESS?</p>
|
||||
|
||||
<p>{description}</p>
|
||||
<p>{data.description}</p>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
||||
17
src/routes/council/+page.server.js
Normal file
17
src/routes/council/+page.server.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { getFromCMS } from 'utils/utils.js';
|
||||
|
||||
// needs to concat and format this text
|
||||
const query = `*[_type == "members"]{
|
||||
name,
|
||||
email,
|
||||
position,
|
||||
positionDescription,
|
||||
"image": image.asset->url,
|
||||
yearProgram
|
||||
}`;
|
||||
|
||||
export const load = async () => {
|
||||
return {
|
||||
members: await getFromCMS(query)
|
||||
};
|
||||
};
|
||||
@@ -1,13 +1,26 @@
|
||||
<script>
|
||||
import CouncilCard from 'components/CouncilCard.svelte';
|
||||
import Section from 'components/Section.svelte';
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<title> ECSESS council </title>
|
||||
|
||||
<Section>
|
||||
<p class="page-title">Meet the council!</p>
|
||||
|
||||
<p>Group picture!</p>
|
||||
<div class="flex flex-row flex-wrap items-center align-middle gap-10 p-4">
|
||||
{#each data.members as councilMember}
|
||||
<CouncilCard
|
||||
name={councilMember.name}
|
||||
position={councilMember.position}
|
||||
email={councilMember.email}
|
||||
positionDescription={councilMember.positionDescription}
|
||||
yearProgram={councilMember.yearProgram}
|
||||
image={councilMember.image}
|
||||
></CouncilCard>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<p>Here are the members of the ECSESS council!</p>
|
||||
<div>
|
||||
|
||||
18
src/utils/utils.js
Normal file
18
src/utils/utils.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { createClient } from '@sanity/client';
|
||||
import { SANITY_ID } from '$env/static/private';
|
||||
|
||||
const client = createClient({
|
||||
projectId: SANITY_ID,
|
||||
dataset: 'production',
|
||||
useCdn: true,
|
||||
apiVersion: '2025-02-06'
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} query the GROQ query from Sanity CMS
|
||||
*/
|
||||
export async function getFromCMS(query) {
|
||||
return await client.fetch(query);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user