Skip to content

Commit

Permalink
use plural 'years' for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane98c committed Dec 5, 2023
1 parent 03ea19f commit 94f7f58
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions components/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useMemo } from 'react'
import { Box } from 'theme-ui'
import Entry from './entry'

const List = ({ posts, year }) => {
const List = ({ posts, years }) => {
const filteredContents = useMemo(() => {
return posts.filter((d) => year[d.date.split('-')[2]])
}, [posts, year])
return posts.filter((d) => years[d.date.split('-')[2]])
}, [posts, years])

return (
<Box>
Expand Down
16 changes: 8 additions & 8 deletions components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import {
import List from './list'

const currentYear = new Date().getFullYear()
const initYear = {}
const initYears = {}

for (let year = 2021; year <= currentYear; year++) {
initYear[year] = true
initYears[year] = true
}

const Settings = ({ setYear, year }) => {
const Settings = ({ setYears, years }) => {
return (
<Group spacing='md'>
<Filter
values={year}
setValues={setYear}
values={years}
setValues={setYears}
label='Filter by year'
showAll
/>
Expand All @@ -31,9 +31,9 @@ const Settings = ({ setYear, year }) => {
}

const Main = ({ showMobileSettings, posts }) => {
const [year, setYear] = useState(initYear)
const [years, setYears] = useState(initYears)

const settings = <Settings setYear={setYear} year={year} />
const settings = <Settings setYears={setYears} years={years} />

return (
<>
Expand Down Expand Up @@ -62,7 +62,7 @@ const Main = ({ showMobileSettings, posts }) => {
{settings}
</Column>
<Column start={[1, 2, 5, 5]} width={[6, 6, 7, 7]}>
<List year={year} posts={posts} />
<List years={years} posts={posts} />
</Column>
</Row>
</>
Expand Down

0 comments on commit 94f7f58

Please sign in to comment.