Skip to content

Commit 13190cb

Browse files
Merge pull request #695 from AnshuPriya-1/fix/deterministic-project-sorting
fix: Ensure deterministic and safe project sorting to prevent hydration issues
2 parents f9a98cd + e8f34e3 commit 13190cb

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/app/projects/page.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ export default function Projects() {
176176
)
177177
const ongoing = projects.filter((p) => p.category === 'Ongoing')
178178

179+
const sortedProjects = [...projects].sort((a, b) =>
180+
(a.name || '').localeCompare(b.name || '', undefined, { sensitivity: 'base' })
181+
)
182+
179183
return (
180184
<>
181185
<Container className="mt-20 mb-28">
@@ -201,12 +205,9 @@ export default function Projects() {
201205
</div>
202206

203207
<div className="mb-16 grid grid-cols-1 gap-x-8 gap-y-16 lg:grid-cols-3">
204-
{projects
205-
.slice()
206-
.sort((a, b) => a.name.localeCompare(b.name))
207-
.map((product) => (
208-
<CardProduct key={product.slug} product={product} />
209-
))}
208+
{sortedProjects.map((product) => (
209+
<CardProduct key={product.slug} product={product} />
210+
))}
210211
</div>
211212

212213
{/*

0 commit comments

Comments
 (0)