Skip to content

Commit

Permalink
Merge pull request #17 from SatyaRajAwasth1/year_faculty-wise-page
Browse files Browse the repository at this point in the history
Fix isues with uniformity
  • Loading branch information
SatyaRajAwasth1 authored Oct 22, 2024
2 parents 9bbb1ec + 1616e25 commit 0ba3e5d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/pages/profiles/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const similarProfiles = allProfiles.filter((p) => p.slug !== entry.slug).slice(0
<div class="text-center mt-12">
<a
href="/profiles"
class="border border-green-500 hover:bg-green-500 text-white py-3 px-6 transition-all duration-300"
class="border border-blue-500 hover:bg-blue-500 text-white py-3 px-6 transition-all duration-300"
>
View All Alumni
</a>
Expand Down
53 changes: 33 additions & 20 deletions src/pages/profiles/index.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import { getCollection } from "astro:content";
import TwoColLayout from "../../layout/TwoColLayout.astro";
import ProfileCard from '../../layout/AlumniCardLayout.astro';
import ProfileCard from "../../layout/AlumniCardLayout.astro";
const allProfiles = await getCollection('profiles');
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) => {
Expand All @@ -21,9 +21,9 @@ const batchMap = allProfiles.reduce((map, profile) => {
// 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);
}
Expand All @@ -33,24 +33,37 @@ const sortedYears = Array.from(batchMap.keys()).sort();
---

<TwoColLayout>
<section class="bg-gray-900 text-white p-4 sm:p-6 lg:p-8 max-h-screen overflow-y-auto">
{sortedYears.map((year) => {
let showAll = false;

return (
<div class="mb-8">
<h3 class="text-lg sm:text-xl lg:text-2xl font-bold flex items-center justify-between">
{year} Batch
</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4 mt-4">
{(showAll ? batchMap.get(year) : batchMap.get(year).slice(0, 3))
.map((profile) => (
<section
class="bg-gray-900 text-white p-4 sm:p-6 lg:p-8 max-h-screen overflow-y-auto"
>
{
sortedYears.map((year) => {
let showAll = false;

return (
<div class="mb-8">
<h3 class="text-lg sm:text-xl lg:text-2xl font-bold flex items-center justify-between">
{year} Batch
</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4 mt-4">
{(showAll
? batchMap.get(year)
: batchMap.get(year).slice(0, 3)
).map((profile) => (
<ProfileCard slug={profile.slug} {...profile.data} />
))}
</div>
</div>
</div>
);
})}
);
})
}
<div class="text-center mt-12">
<a
href="/"
class="border border-blue-500 hover:bg-blue-500 text-white py-3 px-6 transition-all duration-300"
>
Get Back to Home
</a>
</div>
</section>
</TwoColLayout>

0 comments on commit 0ba3e5d

Please sign in to comment.