From b29824453a4d5878540a3776ae7fc29af09dd5fc Mon Sep 17 00:00:00 2001 From: SatyaRajAwasth1 Date: Sun, 13 Oct 2024 13:24:30 +0545 Subject: [PATCH] feature: Adds a card layout for viewing alumni info in a card layout where required & implements on profile highlight and profiles page --- .../homepage/ProfileHighlight.astro | 77 +++---------------- src/content/profiles/2021/satyarajawasth1.md | 2 +- src/layout/AlumniCardLayout.astro | 52 +++++++++++++ src/layout/TwoColLayout.astro | 2 +- src/pages/index.astro | 6 +- src/pages/profiles/index.astro | 50 +++++++++++- src/utils/types.ts | 10 +++ 7 files changed, 125 insertions(+), 74 deletions(-) create mode 100644 src/layout/AlumniCardLayout.astro create mode 100644 src/utils/types.ts diff --git a/src/components/homepage/ProfileHighlight.astro b/src/components/homepage/ProfileHighlight.astro index 23b1686..20c1c72 100644 --- a/src/components/homepage/ProfileHighlight.astro +++ b/src/components/homepage/ProfileHighlight.astro @@ -1,4 +1,5 @@ --- +import AlumniCard from '../../layout/AlumniCardLayout.astro'; import { loadConfig } from "../../utils/loadconfig"; import { getFeaturedProfiles } from "../../utils/loadconfig"; @@ -13,71 +14,17 @@ const featuredProfiles = await getFeaturedProfiles(featuredProfilePaths);

Meet Our Alumni

- { - Array.isArray(featuredProfiles) && featuredProfiles.length > 0 ? ( -
- {featuredProfiles.slice(0, 3).map((alumn) => { - const { name, program, batch, image, slogan, tags, history } = - alumn.data; - return ( -
- {image?.url ? ( - {`Profile - ) : ( -
- No Image Available -
- )} -
-

{name}

- - {program}, Class of {batch} - - {slogan &&

{slogan}

} -
- {tags.map((tag, index) => ( - - {tag} - - ))} -
-
-
    - {history.map((item, index) => ( -
  • - {item.year}: {item.position} at{" "} - {item.company} -
  • - ))} -
-
- -
-
- ); - })} -
- ) : ( -
-

- No alumni profiles available at this time. Please check back later! -

-
- ) - } + { featuredProfiles.length ? ( +
+ {featuredProfiles.slice(0, 3).map((alumn) => ( + + ))} +
+ ) : ( +
+

No alumni profiles available at this time. Please check back later!

+
+ )}
+ {image?.url ? ( + {`Profile + ) : ( +
+ No Image Available +
+ )} +
+
diff --git a/src/layout/TwoColLayout.astro b/src/layout/TwoColLayout.astro index ea4af5e..6ef4142 100644 --- a/src/layout/TwoColLayout.astro +++ b/src/layout/TwoColLayout.astro @@ -8,6 +8,6 @@ const { children } = Astro.props;
- {children} +
\ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index ff8adc8..457fb7e 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,7 +1,5 @@ --- import HomeLayout from "../layout/HomeLayout.astro"; - - --- @@ -13,8 +11,6 @@ import HomeLayout from "../layout/HomeLayout.astro"; NCIT Alumni Portal - -

This is the landing page.

-
+ diff --git a/src/pages/profiles/index.astro b/src/pages/profiles/index.astro index 7598754..db68144 100644 --- a/src/pages/profiles/index.astro +++ b/src/pages/profiles/index.astro @@ -1,8 +1,54 @@ --- +import { getCollection } from "astro:content"; import TwoColLayout from "../../layout/TwoColLayout.astro"; +import ProfileCard from '../../layout/AlumniCardLayout.astro'; +const allProfiles = await getCollection('profiles'); + +// A map to hold data in map with year/batch as key and set of profiles in alphabetical order as value +const batchMap = allProfiles.reduce((map, profile) => { + const batch = profile.data.batch; + + if (!map.has(batch)) { + map.set(batch, new Set()); + } + + map.get(batch).add(profile); + + return map; +}, new Map()); + +// Convert each set to an array and sort by name +for (const [batch, profilesSet] of batchMap.entries()) { + const profilesArray = Array.from(profilesSet); + + profilesArray.sort((a, b) => a.data.name.localeCompare(b.data.name)); + + // Replace the set with the sorted array in the map + batchMap.set(batch, profilesArray); +} + +// Create an array of sorted years/batches +const sortedYears = Array.from(batchMap.keys()).sort(); --- - Featured Profiles go here - \ No newline at end of file + {sortedYears.map((year) => { + let showAll = false; + + return ( +
+

+ {year} Batch +

+
+ {(showAll ? batchMap.get(year) : batchMap.get(year).slice(0, 3)) + .map((profile) => ( + + ))} +
+
+ ); + })} + + diff --git a/src/utils/types.ts b/src/utils/types.ts new file mode 100644 index 0000000..05a3169 --- /dev/null +++ b/src/utils/types.ts @@ -0,0 +1,10 @@ +export interface AlumniProfileInfo { + name: string; + program: string; + batch: string; + image?: { url: string }; + slogan?: string; + tags: string[]; + history: { year: string; position: string; company: string }[]; + slug: string; + }