Skip to content

Commit

Permalink
Use collection.id to give name to list
Browse files Browse the repository at this point in the history
  • Loading branch information
mattobee committed Jun 29, 2024
1 parent 62be34e commit a98baf3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/groupCoursesByCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ console.log(courses);
if (!collectionsMap[collection._id]) {
collectionsMap[collection._id] = {
title: collection.title,
id: collection._id,
description: collection.description,
courses: []
};
Expand Down
11 changes: 6 additions & 5 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import BaseLayout from '../layouts/BaseLayout.astro';
import groupCoursesByCollection from '../groupCoursesByCollection.js';
import Course from '../components/Course.astro';
import { generateUniqueId } from '../utils.js';
// Fetching the courses data
const groupedCourses = await groupCoursesByCollection();
Expand All @@ -11,11 +12,11 @@ const groupedCourses = await groupCoursesByCollection();
<h1 class="sr-only">Accessibility Courses</h1>
{groupedCourses.length > 0 ? (
groupedCourses.map((collection) => (
<section class="collection">
<h2 class="collection__title">{collection.title}</h2>
<ul role="list" class="grid">
{collection.courses.map((course, index) => (
<li key={index}>
<section id={collection.id} class="collection">
<h2 id={`${collection.id}-heading`} class="collection__title">{collection.title}</h2>
<ul role="list" aria-labelledby={`${collection.id}-heading`} class="grid">
{collection.courses.map((course) => (
<li key={course._id}>
<Course course={course} />
</li>
))}
Expand Down

0 comments on commit a98baf3

Please sign in to comment.