Skip to content

Commit 165827d

Browse files
Merge pull request #18 from RishavOsaurus/main
fix: Bug Fixes and Styles Changes
2 parents 0ba3e5d + 4df2451 commit 165827d

File tree

6 files changed

+67
-16
lines changed

6 files changed

+67
-16
lines changed

src/components/shared/LeftSidebar.astro

+30-11
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,46 @@ const yearsRange = Array.from({ length: currentYear - startYear + 1 }, (_, i) =>
5050
const toggleBtn = document.getElementById('toggleBtn');
5151
const closeBtn = document.getElementById('closeBtn');
5252

53+
function updateCloseBtnVisibility() {
54+
if (screen.width > 1080) {
55+
if (closeBtn) closeBtn.classList.add('hidden');
56+
} else {
57+
if (closeBtn) closeBtn.classList.remove('hidden');
58+
}
59+
}
60+
61+
// Initial check
62+
updateCloseBtnVisibility();
63+
64+
// Add resize event listener
65+
window.addEventListener('resize', updateCloseBtnVisibility);
66+
67+
5368
function toggleSidebar() {
5469
console.log("opening sidebar")
55-
const isHidden = sidebar.classList.toggle('-translate-x-full');
56-
backdrop.classList.toggle('hidden', isHidden);
57-
if (!isHidden) {
58-
document.body.style.overflow = 'hidden'; // Disable scrolling
59-
} else {
60-
document.body.style.overflow = ''; // Enable scrolling
70+
if (sidebar) {
71+
const isHidden = sidebar.classList.toggle('-translate-x-full');
72+
if (backdrop) {
73+
backdrop.classList.toggle('hidden', isHidden);
74+
}
75+
if (!isHidden) {
76+
document.body.style.overflow = 'hidden'; // Disable scrolling
77+
} else {
78+
document.body.style.overflow = ''; // Enable scrolling
79+
}
6180
}
6281
}
6382

6483
function closeSidebar() {
6584
console.log("closing sidebar")
66-
sidebar.classList.add('-translate-x-full');
67-
backdrop.classList.add('hidden');
85+
if (sidebar) sidebar.classList.add('-translate-x-full');
86+
if (backdrop) backdrop.classList.add('hidden');
6887
document.body.style.overflow = ''; // Enable scrolling
6988
}
7089

71-
toggleBtn.addEventListener('click', toggleSidebar);
72-
closeBtn.addEventListener('click', closeSidebar);
73-
backdrop.addEventListener('click', closeSidebar);
90+
if (toggleBtn) toggleBtn.addEventListener('click', toggleSidebar);
91+
if (closeBtn) closeBtn.addEventListener('click', closeSidebar);
92+
if (backdrop) backdrop.addEventListener('click', closeSidebar);
7493
});
7594
</script>
7695

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Rishav Chapagain
3+
program: BE Software
4+
batch: '2022'
5+
image:
6+
url: https://avatars.githubusercontent.com/u/113815102?v=4
7+
alt: Rishav Chapagain
8+
tags:
9+
- Backend
10+
- Open Source Contributor
11+
- Writer
12+
history:
13+
- year: '2022'
14+
position: 'Student'
15+
company: 'NCIT'
16+
description: 'Learining Everything tech has to offer'
17+
18+
social:
19+
linkedin: 'https://www.linkedin.com/in/rishav-chapagain'
20+
github: 'https://github.com/rishavosaurus'
21+
twitter: 'https://twitter.com/nerdishav'
22+
slogan: Grades in the mud!
23+
---
24+
25+
I like to read,write and do everything that does not involve conversing or talking with another individual.

src/pages/profiles/[...slug].astro

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ const similarProfiles = allProfiles.filter((p) => p.slug !== entry.slug).slice(0
9696
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
9797
{similarProfiles.map((profile) => (
9898
<div class="p-4 bg-gray-700 rounded-lg shadow-md flex flex-col items-center">
99-
<img src={profile.data.image.url} alt={profile.data.image.alt} class="w-24 h-24 rounded-full mb-2" />
99+
<a href={`/profiles/${profile.slug}`} style="cursor: pointer;" target="_blank" class="flex flex-col gap-1 w-full items-center justify-center">
100+
<img src={profile.data.image.url} alt={profile.data.image.alt} class="w-24 h-24 rounded-full" />
100101
<h3 class="font-bold text-center text-white">{profile.data.name}</h3>
101102
<p class="text-gray-300">{profile.data.program} ({profile.data.batch})</p>
102103
<a href={`/profiles/${profile.slug}`} class="text-blue-400 mt-2">View Profile</a>
104+
</a>
103105
</div>
104106
))}
105107
</div>

src/pages/profiles/[faculty].astro

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const { profiles } = Astro.props;
6464
<p class="mt-4 text-center text-lg">
6565
Don’t see the profile you were looking for?
6666
<a
67+
style="margin-left: 1rem;"
6768
href="/add-profile"
6869
class="mt-4 inline-block border border-green-500 hover:bg-green-500 text-white py-2 px-4 transition-all duration-300 rounded"
6970
>

src/pages/profiles/[year].astro

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ const { profiles } = Astro.props;
6363
))}
6464
</div>
6565
<p class="mt-4 text-center text-lg">
66-
Dont see the profile you were looking for?
66+
Don't see the profile you were looking for?
6767
<a
68+
style="margin-left: 1rem;"
6869
href="/add-profile"
6970
class="mt-4 inline-block border border-green-500 hover:bg-green-500 text-white py-2 px-4 transition-all duration-300 rounded"
7071
>

src/pages/profiles/index.astro

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { getCollection } from "astro:content";
33
import TwoColLayout from "../../layout/TwoColLayout.astro";
44
import ProfileCard from "../../layout/AlumniCardLayout.astro";
55
6-
const allProfiles = await getCollection("profiles");
6+
import type { CollectionEntry } from "astro:content";
7+
8+
const allProfiles: CollectionEntry<"profiles">[] = await getCollection("profiles");
79
810
// A map to hold data in map with year/batch as key and set of profiles in alphabetical order as value
911
const batchMap = allProfiles.reduce((map, profile) => {
@@ -21,8 +23,9 @@ const batchMap = allProfiles.reduce((map, profile) => {
2123
// Convert each set to an array and sort by name
2224
for (const [batch, profilesSet] of batchMap.entries()) {
2325
const profilesArray = Array.from(profilesSet);
26+
profilesArray.sort((a: CollectionEntry<"profiles">, b: CollectionEntry<"profiles">) => a.data.name.localeCompare(b.data.name));
2427
25-
profilesArray.sort((a, b) => a.data.name.localeCompare(b.data.name));
28+
profilesArray.sort((a: CollectionEntry<"profiles">, b: CollectionEntry<"profiles">) => a.data.name.localeCompare(b.data.name));
2629
2730
// Replace the set with the sorted array in the map
2831
batchMap.set(batch, profilesArray);
@@ -62,7 +65,7 @@ const sortedYears = Array.from(batchMap.keys()).sort();
6265
href="/"
6366
class="border border-blue-500 hover:bg-blue-500 text-white py-3 px-6 transition-all duration-300"
6467
>
65-
Get Back to Home
68+
Home
6669
</a>
6770
</div>
6871
</section>

0 commit comments

Comments
 (0)