Skip to content

Commit

Permalink
bug: remove useless Vercel serverless function
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Lau committed May 26, 2023
1 parent f55b5c6 commit 395d2f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 97 deletions.
4 changes: 2 additions & 2 deletions data/toolsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface GearType {
legacy?: boolean
}

const toolsData: GearType[] = [
const gearsData: GearType[] = [
{
type: 'Coding',
name: 'VS Code - Code Editor',
Expand Down Expand Up @@ -54,4 +54,4 @@ const toolsData: GearType[] = [
{ type: 'Misc', name: 'Huawei P30 Pro' },
]

export default toolsData
export default gearsData
65 changes: 0 additions & 65 deletions pages/api/gear.ts

This file was deleted.

47 changes: 17 additions & 30 deletions pages/gears.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ import React from 'react'
import PageLayout from '@components/layout/PageLayout'
import { Link } from '@components/ui'
import Condition from '@components/common/Condition'
import useSWR from 'swr'
import { GearType } from '@data/toolsData'

const fetcher = (url: string) => fetch(url).then((res) => res.json())
import gearsData from '@data/toolsData'

const Gears = () => {
const {
data: toolsData,
isLoading,
error,
} = useSWR<GearType[]>('/api/gear', fetcher)

if (isLoading) return <h1>loading</h1>

const toolsTypeList = [...new Set(toolsData?.map((item) => item.type))]
const gearCategory = [...new Set(gearsData?.map((item) => item.type))]

return (
<PageLayout
Expand All @@ -38,28 +27,26 @@ const Gears = () => {
/>
</Grid>
<Grid container item xs={12} spacing={4}>
{error && error}
{toolsTypeList?.map((type) => (
{gearCategory?.map((type) => (
<Grid item xs={12} key={type}>
<Typography variant='h5' component={'h4'}>
{type}
</Typography>

{toolsData &&
toolsData.map(
(ele) =>
ele.type === type && (
<Typography>
{ele.name}
<Condition condition={!!ele.link}>
{' - '}
<Link underline='always' href={ele.link as string}>
Link to goodies
</Link>
</Condition>
</Typography>
)
)}
{gearsData.map(
(ele) =>
ele.type === type && (
<Typography>
{ele.name}
<Condition condition={!!ele.link}>
{' - '}
<Link underline='always' href={ele.link as string}>
Link to goodies
</Link>
</Condition>
</Typography>
)
)}
</Grid>
))}
</Grid>
Expand Down

0 comments on commit 395d2f1

Please sign in to comment.