unstable typescript
This commit is contained in:
1 parent
274e1e7fc0
commit
b35e4e36e2
19 files changed
+658
-286
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import React from 'react'
|
||||
import Head from 'next/head'
|
||||
import { App } from '../src/components/App'
|
||||
import { Meta } from '../src/components/Meta'
|
||||
import { ArticleCardList } from '../src/components/ArticleCardList'
|
||||
import { HudozkaTitle } from '../src/components/HudozkaTitle'
|
||||
import menuModel from '../src/models/menu'
|
||||
import { meta } from '../src/lib/meta'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
import { createApiUrl, requestGet, wrapInitialProps } from '../src/next-lib'
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<Head>
|
||||
<title>{props.title}</title>
|
||||
<Meta meta={props.meta} />
|
||||
</Head>
|
||||
|
||||
<div className="content content_wide">
|
||||
<HudozkaTitle />
|
||||
|
||||
<ArticleCardList
|
||||
articles={props.articles}
|
||||
prevPage={props.prevPage}
|
||||
nextPage={props.nextPage}
|
||||
/>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
||||
const pageUrl = '/'
|
||||
const page = 1
|
||||
const pageSize = ctx.query.pageSize || 15
|
||||
const res = await requestGet(createApiUrl(ctx.req, `/api/articles?page=${page}&pageSize=${pageSize}`), {})
|
||||
const articles = res.items || []
|
||||
const nextPage = res.nextPage
|
||||
const prevPage = res.prevPage
|
||||
const title = 'Шлиссельбургская ДХШ'
|
||||
|
||||
return {
|
||||
articles,
|
||||
nextPage,
|
||||
prevPage,
|
||||
pageUrl,
|
||||
title,
|
||||
meta: meta({
|
||||
title,
|
||||
url: pageUrl,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export default Page
|
||||
Reference in new issue
Block a user