TaeHee Kim
Software Engineer / Bassist
김태희/로토
인디 뮤지션들의 뮤지션 정보 및 공연 정보 등을
아카이빙 하는 사이트
기존에 있던 사이트에서 url만 이어받아서
2021년 2월부터 새로 만들기 시작했습니다.
대충_잼이_쌓여있는_사진.png
JavaScript
APIs
Markup
export const getStaticPaths: GetStaticPaths = async ({ locales }) => {
if (process.env.NEXT_PUBLIC_ENABLE_PREBUILD === 'Y') {
const apolloClient = initializeApollo({})
const result = await apolloClient.query<LiveListQuery>({
query: LiveListDocument,
variables: {
start: 0,
limit: 100,
sort: 'startDate:DESC',
},
})
const paths =
flatten(
result.data?.lives?.flatMap(live =>
isNil(live) || isNil(locales)
? []
: [
locales.map(locale => ({
params: {
liveId: live.id,
},
locale,
})),
]
)
) ?? []
return {
paths,
fallback: true,
}
}
return {
paths: [],
fallback: true,
}
}
export const getStaticProps: GetStaticProps<{ liveId: string }> = async ({ params }) => {
const liveId = getParamsValue(params, 'liveId')
if (isNil(liveId)) {
return {
notFound: true,
}
}
const apolloClient = initializeApollo({})
const res = await apolloClient.query<FindOneLiveQuery>({
query: FindOneLiveDocument,
variables: {
id: liveId,
},
})
if (!res.data.live) {
return {
notFound: true,
}
}
return {
props: {
initialApolloState: apolloClient.cache.extract(),
liveId,
},
revalidate: 60,
}
}
indistreet 많이 써주세요!!
By TaeHee Kim