Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
2020-05-26 00:25:18 +02:00
parent fee40613f1
commit 59a0862d58
7 changed files with 15 additions and 37 deletions

View File

@ -24,11 +24,16 @@ interface States {
export default class PostPage extends Component<Props, States> {
public static async getInitialProps(context: NextPageContext) {
const { slug } = context.query
if (typeof slug === 'object' || slug === '[slug]') {
const { slug, category } = context.query
if (
typeof slug === 'object' ||
slug === '[slug]' ||
typeof category === 'object' ||
category === '[category]'
) {
return {post: undefined}
}
const post = new Post(slug)
const post = new Post(`${category}/${slug}`)
await post.fetch()
return {post}
}