File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 11import React from 'react'
22import { PageLayout } from './PageLayout'
3- import { Drawing } from '../types'
43import { DrawingTile } from './DrawingTile'
54import Link from 'next/link'
65import styled from 'styled-components'
76import { getPreviousDay , getNextDay } from '../lib/drawings'
87import { useRouter } from 'next/router'
98import Div100vh from 'react-div-100vh'
9+ import { dayDrawingSets } from '../__fixtures__/drawings'
1010
11- export const DayPage : React . FC < { drawings : Drawing [ ] , day : string } > = ( { drawings, day } ) => {
12- const year = parseInt ( day . slice ( 0 , 4 ) , 10 )
11+ export const DayPage : React . FC < { day : string } > = ( { day } ) => {
12+ const drawings = dayDrawingSets [ day ]
13+ const year = drawings [ 0 ] . year
1314 const router = useRouter ( )
1415 const goToPrevious = ( ) => router . push ( `/day/${ getPreviousDay ( day ) } ` )
1516 const goToNext = ( ) => router . push ( `/day/${ getNextDay ( day ) } ` )
Original file line number Diff line number Diff line change @@ -3,8 +3,10 @@ import { PageLayout } from './PageLayout'
33import { DrawingTile } from './DrawingTile'
44import styled from 'styled-components'
55import { YearBar } from './YearBar'
6+ import { yearDrawingSets } from '../__fixtures__/drawings'
67
7- export const YearPage : React . FC < { drawings : Drawing [ ] , year : number } > = ( { drawings, year } ) => {
8+ export const YearPage : React . FC < { year : number } > = ( { year } ) => {
9+ const drawings = yearDrawingSets [ year ]
810 return (
911 < PageLayout title = { `explodingdog ${ year } ` } >
1012 < YearBar activeYear = { year } />
Original file line number Diff line number Diff line change 11import { DayPage } from '../../components/DayPage'
22import { GetStaticProps , GetStaticPaths } from 'next'
3- import { dayDrawingSets , drawingDays } from '../../__fixtures__/drawings'
3+ import { drawingDays } from '../../__fixtures__/drawings'
44import { singleQueryParamValue } from '../../lib/next'
55
66export default DayPage
77
88export const getStaticPaths : GetStaticPaths = async ( ) => {
9- const paths = drawingDays . map ( day => ( { params : { id : day . toString ( ) } } ) )
9+ const paths = drawingDays . map ( day => ( { params : { id : day } } ) )
1010 return { paths, fallback : false }
1111}
1212
1313export const getStaticProps : GetStaticProps = async ( { params } ) => {
1414 const day = singleQueryParamValue ( params ?. id )
15- return { props : { day, drawings : dayDrawingSets [ day ] } }
15+ return { props : { day } }
1616}
Original file line number Diff line number Diff line change 11import { YearPage } from '../../components/YearPage'
22import { GetStaticProps , GetStaticPaths } from 'next'
3- import { drawingYears , yearDrawingSets } from '../../__fixtures__/drawings'
3+ import { drawingYears } from '../../__fixtures__/drawings'
44
55export default YearPage
66
77export const getStaticPaths : GetStaticPaths = async ( ) => {
8- const paths = drawingYears . map ( year => ( { params : { id : year . toString ( ) } } ) )
8+ const paths = drawingYears . map ( year => ( { params : { id : ` ${ year } ` } } ) )
99 return { paths, fallback : false }
1010}
1111
1212export const getStaticProps : GetStaticProps = async ( { params } ) => {
1313 const year = Number ( params ?. id )
14- return { props : { year, drawings : yearDrawingSets [ year ] } }
14+ return { props : { year } }
1515}
You can’t perform that action at this time.
0 commit comments