diff --git a/src/components/Course.astro b/src/components/Course.astro index 9352682..80dc5dc 100644 --- a/src/components/Course.astro +++ b/src/components/Course.astro @@ -1,6 +1,6 @@ --- let { course } = Astro.props; -let { title, website, description, provider } = course; +let { title, website, description, provider, teacher } = course; ---
@@ -10,8 +10,13 @@ let { title, website, description, provider } = course; the provider's name as text --> {provider.map((provider: { website: string | URL; name: unknown; }, index: any) => provider.website - ? {provider.name} - : {provider.name} + ? Provider: {provider.name} + : Provider: {provider.name} + )} + {teacher.map((teacher: { website: string | URL; name: unknown; }, index: any) => + teacher.website + ? Teacher: {teacher.name} + : Teacher: {teacher.name} )}

{description}

Find out more about {title} diff --git a/src/getCourses.js b/src/getCourses.js index 628b2c7..8ce570a 100644 --- a/src/getCourses.js +++ b/src/getCourses.js @@ -4,19 +4,21 @@ import { sanityClient } from "sanity:client"; async function getCourses() { try { // Fetch all courses from Sanity that are not drafts - // The 'provider' field is an array of references, so we use 'provider[]->' to dereference each reference and get the actual data + // The 'provider' and 'teacher' fields are arrays of references, so we use 'provider[]->' and 'teacher[]->' to dereference each reference and get the actual data const courses = await sanityClient.fetch(`*[_type == "course" && !(_id in path("drafts.**"))]{ ..., - "provider": provider[]-> + "provider": provider[]->, + "teacher": teacher[]-> }`); // Map over the courses - // For each course, we spread the existing course data and then check if 'provider' exists - // If 'provider' exists, we map over it and return the provider data - // If 'provider' doesn't exist, we return an empty array + // For each course, we spread the existing course data and then check if 'provider' and 'teacher' exist + // If 'provider' or 'teacher' exist, we map over them and return the provider or teacher data + // If 'provider' or 'teacher' don't exist, we return an empty array return courses.map(course => ({ ...course, provider: course.provider ? course.provider.map(provider => provider) : [], + teacher: course.teacher ? course.teacher.map(teacher => teacher) : [], })); } catch (error) { // If an error occurs, log it to the console and throw an error diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index ab2064e..1eedfb4 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -12,6 +12,9 @@ import '../styles/styles.css'; {title ? `${title} - a11y.courses` : "a11y.courses"} + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index 1968750..120a1bd 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -10,19 +10,21 @@ const courses = await getCourses(); console.log(courses); --- -

a11y.courses

- {/* Checking if courses is an array and if it has any elements */} - {Array.isArray(courses) && courses.length > 0 ? ( - - ) : ( - // If there are no courses, display a message -

There are no courses to display

- )} +
+

Accessibility Courses

+ {/* Checking if courses is an array and if it has any elements */} + {Array.isArray(courses) && courses.length > 0 ? ( +
    + {/* Rendering a Course component for each course */} + {courses.map((course, index) => ( +
  • + +
  • + ))} +
+ ) : ( + // If there are no courses, display a message +

There are no courses to display.

+ )} +
\ No newline at end of file diff --git a/src/styles/typo.css b/src/styles/typo.css index f9f5e34..1db3132 100644 --- a/src/styles/typo.css +++ b/src/styles/typo.css @@ -1,13 +1,23 @@ body { color: var(--color-text); + font-family: "Atkinson Hyperlegible", sans-serif; + font-weight: 400; + font-style: normal; + font-size: var(--step-0); } h1 { - font-size: var(--step-5); + font-size: var(--step-3); + font-family: "Poppins", sans-serif; } h2 { - font-size: var(--step-4); + font-size: var(--step-2); + font-family: "Poppins", sans-serif; } h3 { font-size: var(--step-3); +} + +small { + font-size: var(--step--1); } \ No newline at end of file