FAQ Accordion using Skeleton UI

This commit is contained in:
Antoine Phan
2025-06-14 01:08:49 -04:00
parent f3285c21fd
commit 469bc6ba85
3 changed files with 92 additions and 39 deletions

View File

@@ -2,7 +2,8 @@ import { getFromCMS } from 'utils/utils.js';
const homepageQuery = `*[_type == "homepage"]{
"description": description[],
"councilPhoto": councilPhoto.asset->url
"councilPhoto": councilPhoto.asset->url,
"faqs": faqs[]{ question, answer },
}[0]`;
const ohQuery = `*[_type=="oh"].schedule[]{
@@ -13,12 +14,26 @@ const ohQuery = `*[_type=="oh"].schedule[]{
}`;
export const load = async () => {
/**
* @description Response data type based on the `homepageQuery` above.
* Note that `description` is a rich/portable text type
*
* @type {{
* description: import('@portabletext/svelte').InputValue,
* councilPhoto: string,
* faqs: [{
* question: string,
* answer: string
* }],
* }}
*
*/
let CMSresponse = await getFromCMS(homepageQuery);
return {
description: CMSresponse.description,
councilPhoto: CMSresponse.councilPhoto
councilPhoto: CMSresponse.councilPhoto,
faqs: CMSresponse.faqs
// ohs: await getFromCMS(ohQuery),
// FAQs: "",
};
};

View File

@@ -5,25 +5,6 @@
/** loading things from the server side */
let { data } = $props();
// Getting info from ECSESS CMS
let longAnswer =
'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 faqs = [
{
q: 'A fequently asked question?',
a: 'This is a short answer'
},
{
q: 'A fequently asked question?',
a: 'This is a medium length answer. Lor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
},
{
q: 'A fequently asked question?',
a: 'This is a long answer. ' + longAnswer
}
];
</script>
<title> McGill ECSESS </title>
@@ -46,9 +27,7 @@
</div>
<div>
<h1>FAQ</h1>
{#each faqs as { q, a }}
<FaqAccordion entry={{ title: q, description: a }} />
{/each}
<FaqAccordion entries={data.faqs} />
</div>
</Section>
<!-- Office Hours Calendar -->