import { GetServerSideProps , GetServerSidePropsContext } from 'next' ; import Layout from '../components/Layout' ; import { Topic } from '../interfaces' ; import { getTopicList } from '../apis' ; import { TopicList } from '../components/TopicList' ; interface Props { tab : string ; topics : Topic [ ] ; } const TopicsPage = ( { tab , topics } ) => { return ( < Layout title = { `${ tab } | Serverless V2EX` } > < TopicList topics = { topics } /> < /Layout>); } ; export const getServerSideProps = async ( context ) => { const { query = { } } = context ; const tab = query . tab ? ( query . tab as string ) : 'latest' ; const topics = await getTopicList ( tab ) ; return { props : { topics , tab } } ; } ; export default TopicsPage ;