index page updated to static export
This commit is contained in:
1 parent
4de352e2df
commit
3103f3689b
2 files changed
+24
-22
No files matched your search
+2
-2
@@ -17,7 +17,7 @@ function createPath(page, map, query, items) {
|
|||||||
module.exports = withCss(withSass({
|
module.exports = withCss(withSass({
|
||||||
exportTrailingSlash: true,
|
exportTrailingSlash: true,
|
||||||
env: {
|
env: {
|
||||||
ARTICLES_PAGE_SIZE: 15,
|
APP_ARTICLES_PAGE_SIZE: 15,
|
||||||
},
|
},
|
||||||
webpack(config) {
|
webpack(config) {
|
||||||
config.resolve.modules.push(__dirname)
|
config.resolve.modules.push(__dirname)
|
||||||
@@ -33,7 +33,7 @@ module.exports = withCss(withSass({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
// ...defaultPathMap,
|
// ...defaultPathMap,
|
||||||
'/': { page: '/', query: { pageSize: articlesPageSize } },
|
'/': { page: '/' },
|
||||||
'/documents': { page: '/documents' },
|
'/documents': { page: '/documents' },
|
||||||
'/gallery': { page: '/gallery' },
|
'/gallery': { page: '/gallery' },
|
||||||
'/collective': { page: '/collective' },
|
'/collective': { page: '/collective' },
|
||||||
|
|||||||
+22
-20
@@ -1,13 +1,13 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import { App } from '../src/components/App'
|
import { App } from 'src/components/App'
|
||||||
import { Meta } from '../src/components/Meta'
|
import { Meta } from 'src/components/Meta'
|
||||||
import { ArticleCardList } from '../src/components/ArticleCardList'
|
import { ArticleCardList } from 'src/components/ArticleCardList'
|
||||||
import { HudozkaTitle } from '../src/components/HudozkaTitle'
|
import { HudozkaTitle } from 'src/components/HudozkaTitle'
|
||||||
import menuModel from '../src/models/menu'
|
import menuModel from 'src/models/menu'
|
||||||
import { meta } from '../src/lib/meta'
|
import { meta } from 'src/lib/meta'
|
||||||
import { buildMenu } from '../src/lib/menu'
|
import { buildMenu } from 'src/lib/menu'
|
||||||
import { createApiUrl, requestGet, wrapInitialProps } from '../src/next-lib'
|
import { createApiUrl, requestGet } from 'src/next-lib'
|
||||||
import { NextPage } from 'next'
|
import { NextPage } from 'next'
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@@ -41,10 +41,10 @@ const Page: NextPage<IProps> = props => (
|
|||||||
</App>
|
</App>
|
||||||
)
|
)
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
export const unstable_getStaticProps = async () => {
|
||||||
const pageUrl = '/'
|
const pageUrl = '/'
|
||||||
const page = 1
|
const page = 1
|
||||||
const pageSize = ctx.query.pageSize || 15
|
const pageSize = process.env.APP_ARTICLES_PAGE_SIZE
|
||||||
const res = await requestGet(createApiUrl(`/api/articles?page=${page}&pageSize=${pageSize}`), {}) as any
|
const res = await requestGet(createApiUrl(`/api/articles?page=${page}&pageSize=${pageSize}`), {}) as any
|
||||||
const articles = res.items || []
|
const articles = res.items || []
|
||||||
const nextPage = res.nextPage
|
const nextPage = res.nextPage
|
||||||
@@ -52,16 +52,18 @@ Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
|||||||
const title = 'Шлиссельбургская ДХШ'
|
const title = 'Шлиссельбургская ДХШ'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
articles,
|
props: {
|
||||||
nextPage,
|
articles,
|
||||||
prevPage,
|
nextPage,
|
||||||
pageUrl,
|
prevPage,
|
||||||
title,
|
pageUrl,
|
||||||
meta: meta({
|
|
||||||
title,
|
title,
|
||||||
url: pageUrl,
|
meta: meta({
|
||||||
})
|
title,
|
||||||
|
url: pageUrl,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
export default Page
|
export default Page
|
||||||
Reference in new issue
Block a user