-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
292 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
import Error from 'next/error' | ||
import Grouping from '../../components/grouping' | ||
import Years from '../../components/years' | ||
import { map, filter, orderBy, startsWith, split, first, uniq } from 'lodash' | ||
import { getEvents, getGroupingData } from '../../lib/data' | ||
|
||
export default ({ year, events, groups }) => ( | ||
<Grouping title={`${year} Events`} events={events} groups={groups}> | ||
<Years showAll /> | ||
</Grouping> | ||
) | ||
export default ({ year, events, groups }) => { | ||
if (!year || !events) return <Error statusCode={404} /> | ||
return ( | ||
<Grouping title={`${year} Events`} events={events} groups={groups}> | ||
<Years showAll /> | ||
</Grouping> | ||
) | ||
} | ||
|
||
export async function unstable_getStaticPaths() { | ||
let events = await getEvents() | ||
let starts = map(filter(events, { group_id: null }), 'start') | ||
starts = map(starts, start => first(split(start, '-'))) | ||
let years = uniq(starts) | ||
return map(years, year => ({ params: { year } })) | ||
const paths = map(years, year => ({ params: { year } })) | ||
return { paths } | ||
} | ||
|
||
export async function unstable_getStaticProps({ params }) { | ||
const { year } = params | ||
let { events, groups } = await getGroupingData() | ||
events = orderBy( | ||
filter(events, e => startsWith(e.start, year)), | ||
'start' | ||
) | ||
events = orderBy(filter(events, e => startsWith(e.start, year)), 'start') | ||
return { props: { year, events, groups } } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
singleQuote: true, | ||
trailingComma: false, | ||
trailingComma: 'none', | ||
printWidth: 80, | ||
semi: false | ||
} |
Oops, something went wrong.