Skip to content

Commit

Permalink
Update order of cards on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
DinerIsmail committed Sep 30, 2023
1 parent 6a94a4a commit 3eb2797
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions components/homepage/web-cards/WebCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { Container, Stack, Grid, Heading, Box, Link } from '@chakra-ui/react'
import { PROTOCOL, REMOTE_HOSTNAME } from '@helpers/config'
import { useWebs } from '@hooks/webs'

// Hardcoded array to determine which webs are displayed first
const orderOnHomepage = ['Cambridge', 'York', 'Durham']

const WebCards = () => {
const { webs } = useWebs()

Expand All @@ -25,9 +28,14 @@ const WebCards = () => {
(web) =>
web.published && Boolean(web.image) && web.slug !== 'ctrlshift',
)
.map((web) => (
<Card key={web.id} web={web} />
))}
.sort((a, b) => {
if (orderOnHomepage.includes(a.title) > orderOnHomepage.includes(b.title)) {
return -1
} else {
return 1
}
})
.map((web) => <Card key={web.id} web={web} />)}
</Grid>
</Container>
)
Expand Down Expand Up @@ -82,3 +90,10 @@ const Card = ({ web }) => {










1 comment on commit 3eb2797

@vercel
Copy link

@vercel vercel bot commented on 3eb2797 Sep 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.