pages worked as static
This commit is contained in:
1 parent
b9c2929bc3
commit
ca58994301
12 files changed
+414
-258
No files matched your search
@@ -50,7 +50,6 @@ export const unstable_getStaticProps = async (ctx: any) => {
|
|||||||
const id = ctx.params.slug
|
const id = ctx.params.slug
|
||||||
const data = await requestGet(createApiUrl(`/api/albums/${id}`), null)
|
const data = await requestGet(createApiUrl(`/api/albums/${id}`), null)
|
||||||
|
|
||||||
console.log('call album unstable_getStaticProps', data)
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw new Error(`kek ${id}`)
|
throw new Error(`kek ${id}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import Head from 'next/head'
|
|
||||||
import { get } from 'lodash'
|
|
||||||
import { App } from '../../src/components/App'
|
|
||||||
import Article from '../../src/components/Article'
|
|
||||||
import Html from '../../src/components/Html'
|
|
||||||
import menuModel from '../../src/models/menu'
|
|
||||||
import { buildMenu } from '../../src/lib/menu'
|
|
||||||
import { Meta } from '../../src/components/Meta'
|
|
||||||
import { meta } from '../../src/lib/meta'
|
|
||||||
import { createApiUrl, requestGet, wrapInitialProps } from '../../src/next-lib'
|
|
||||||
|
|
||||||
const Page = (props) => (
|
|
||||||
<App
|
|
||||||
menu={buildMenu(props.pageUrl, menuModel)}
|
|
||||||
showAuthor={true}
|
|
||||||
menuPadding={true}
|
|
||||||
layout={'thin'}
|
|
||||||
>
|
|
||||||
<Head>
|
|
||||||
<title>{props.article.title}</title>
|
|
||||||
<Meta meta={props.meta} />
|
|
||||||
</Head>
|
|
||||||
<Article
|
|
||||||
title={props.article.title}
|
|
||||||
date={props.article.date}
|
|
||||||
tags={props.article.tags}
|
|
||||||
shareable={true}
|
|
||||||
>
|
|
||||||
<Html
|
|
||||||
html={props.article.post}
|
|
||||||
/>
|
|
||||||
</Article>
|
|
||||||
</App>
|
|
||||||
)
|
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
|
||||||
const pageUrl = '/'
|
|
||||||
const id = ctx.query.article
|
|
||||||
const article = await requestGet(createApiUrl(`/api/articles/${id}`), {})
|
|
||||||
const image = get(article, 'preview.artifacts.fb', {})
|
|
||||||
|
|
||||||
return {
|
|
||||||
article,
|
|
||||||
pageUrl,
|
|
||||||
meta: meta({
|
|
||||||
title: article.title,
|
|
||||||
image: image.src,
|
|
||||||
imageWidth: image.width,
|
|
||||||
imageHeight: image.height,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default Page
|
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import Head from 'next/head'
|
||||||
|
import { get } from 'lodash'
|
||||||
|
import { App } from 'src/components/App'
|
||||||
|
import Article from 'src/components/Article'
|
||||||
|
import Html from 'src/components/Html'
|
||||||
|
import menuModel from 'src/models/menu'
|
||||||
|
import { buildMenu } from 'src/lib/menu'
|
||||||
|
import { Meta } from 'src/components/Meta'
|
||||||
|
import { meta } from 'src/lib/meta'
|
||||||
|
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
||||||
|
import { NextPage } from 'next'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
pageUrl: string
|
||||||
|
meta: any
|
||||||
|
data: any //(article)
|
||||||
|
}
|
||||||
|
|
||||||
|
const Page: NextPage<Props> = props => {
|
||||||
|
if (!props.data) {
|
||||||
|
console.log('kek error', props)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<App
|
||||||
|
menu={buildMenu(props.pageUrl, menuModel)}
|
||||||
|
showAuthor={true}
|
||||||
|
menuPadding={true}
|
||||||
|
layout={'thin'}
|
||||||
|
>
|
||||||
|
<Head>
|
||||||
|
<title>{props.data.title}</title>
|
||||||
|
<Meta meta={props.meta} />
|
||||||
|
</Head>
|
||||||
|
<Article
|
||||||
|
title={props.data.title}
|
||||||
|
date={props.data.date}
|
||||||
|
tags={props.data.tags}
|
||||||
|
shareable={true}
|
||||||
|
>
|
||||||
|
<Html
|
||||||
|
html={props.data.post}
|
||||||
|
/>
|
||||||
|
</Article>
|
||||||
|
</App>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticProps = async (ctx: any) => {
|
||||||
|
const pageUrl = '/'
|
||||||
|
const id = ctx.params.slug
|
||||||
|
const data = await requestGet(createApiUrl(`/api/articles/${id}`), null)
|
||||||
|
if (!data) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const image = get(data, 'preview.artifacts.fb', {})
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
data,
|
||||||
|
pageUrl,
|
||||||
|
meta: meta({
|
||||||
|
title: data.title,
|
||||||
|
image: image.src,
|
||||||
|
imageWidth: image.width,
|
||||||
|
imageHeight: image.height,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticPaths = async () => {
|
||||||
|
console.log('call article unstable_getStaticPaths')
|
||||||
|
|
||||||
|
const urls = await requestGet<IResponseItems<string>>(createApiUrl(`/api/articles/urls`), null)
|
||||||
|
if (!urls) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
paths: urls.items
|
||||||
|
.map(x => x.replace('/article/', ''))
|
||||||
|
.map(slug => {
|
||||||
|
return {
|
||||||
|
params: {
|
||||||
|
slug,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Page
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import Head from 'next/head'
|
|
||||||
import { App } from '../../src/components/App'
|
|
||||||
import { ArticleCardList } from '../../src/components/ArticleCardList'
|
|
||||||
import menuModel from '../../src/models/menu'
|
|
||||||
import { buildMenu } from '../../src/lib/menu'
|
|
||||||
import { meta } from '../../src/lib/meta'
|
|
||||||
import { Meta } from '../../src/components/Meta'
|
|
||||||
import { createApiUrl, requestGet, wrapInitialProps } from '../../src/next-lib'
|
|
||||||
|
|
||||||
const Page = (props) => (
|
|
||||||
<App
|
|
||||||
menu={buildMenu(props.pageUrl, menuModel)}
|
|
||||||
showAuthor={true}
|
|
||||||
menuPadding={true}
|
|
||||||
layout={'wide'}
|
|
||||||
>
|
|
||||||
<Head>
|
|
||||||
<title>{props.title}</title>
|
|
||||||
<Meta meta={props.meta} />
|
|
||||||
</Head>
|
|
||||||
<ArticleCardList
|
|
||||||
articles={props.articles}
|
|
||||||
prevPage={props.prevPage}
|
|
||||||
nextPage={props.nextPage}
|
|
||||||
/>
|
|
||||||
</App>
|
|
||||||
)
|
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
|
||||||
const pageUrl = '/'
|
|
||||||
const page = parseInt(ctx.query.page)
|
|
||||||
const pageSize = parseInt(ctx.query.pageSize) || 15
|
|
||||||
const res = await requestGet(createApiUrl(`/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,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default Page
|
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
import Head from 'next/head'
|
||||||
|
import { range } from 'lodash'
|
||||||
|
import { App } from 'src/components/App'
|
||||||
|
import { ArticleCardList } from 'src/components/ArticleCardList'
|
||||||
|
import menuModel from 'src/models/menu'
|
||||||
|
import { buildMenu } from 'src/lib/menu'
|
||||||
|
import { meta } from 'src/lib/meta'
|
||||||
|
import { Meta } from 'src/components/Meta'
|
||||||
|
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
||||||
|
import { NextPage } from 'next'
|
||||||
|
|
||||||
|
const pageSize = Number(process.env.APP_ARTICLES_PAGE_SIZE)
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
pageUrl: string
|
||||||
|
meta: any
|
||||||
|
title: string
|
||||||
|
data: any //(list of article)
|
||||||
|
nextPage: number
|
||||||
|
prevPage: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const Page: NextPage<Props> = props => {
|
||||||
|
if (!props.data) {
|
||||||
|
console.log('kek error', props)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<App
|
||||||
|
menu={buildMenu(props.pageUrl, menuModel)}
|
||||||
|
showAuthor={true}
|
||||||
|
menuPadding={true}
|
||||||
|
layout={'wide'}
|
||||||
|
>
|
||||||
|
<Head>
|
||||||
|
<title>{props.title}</title>
|
||||||
|
<Meta meta={props.meta} />
|
||||||
|
</Head>
|
||||||
|
<ArticleCardList
|
||||||
|
articles={props.data}
|
||||||
|
prevPage={props.prevPage}
|
||||||
|
nextPage={props.nextPage}
|
||||||
|
/>
|
||||||
|
</App>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticProps = async (ctx: any) => {
|
||||||
|
const pageUrl = '/'
|
||||||
|
// const page = parseInt(ctx.query.page)
|
||||||
|
const page = parseInt(ctx.params.slug)
|
||||||
|
const res = await requestGet<IResponseItems<any[]>>(
|
||||||
|
createApiUrl(`/api/articles?page=${page}&pageSize=${pageSize}`),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
if (!res) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = res.items || []
|
||||||
|
const nextPage = (res as any).nextPage
|
||||||
|
const prevPage = (res as any).prevPage
|
||||||
|
const title = 'События'
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
data,
|
||||||
|
nextPage,
|
||||||
|
prevPage,
|
||||||
|
pageUrl,
|
||||||
|
title,
|
||||||
|
meta: meta({
|
||||||
|
title,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticPaths = async () => {
|
||||||
|
console.log('call articles unstable_getStaticPaths')
|
||||||
|
|
||||||
|
const urls = await requestGet<IResponseItems<string>>(createApiUrl(`/api/articles/urls`), null)
|
||||||
|
if (!urls) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const count = urls.items.length
|
||||||
|
const pages = Math.ceil(count / pageSize)
|
||||||
|
|
||||||
|
return {
|
||||||
|
paths: range(1, pages + 1)
|
||||||
|
.map(i => {
|
||||||
|
return {
|
||||||
|
params: {
|
||||||
|
slug: `${i}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default Page
|
||||||
+44
-36
@@ -21,50 +21,58 @@ type Props = {
|
|||||||
title: string
|
title: string
|
||||||
image: string
|
image: string
|
||||||
meta: IMeta
|
meta: IMeta
|
||||||
persons: IPerson[]
|
data: IPerson[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Page: NextPage<Props> = props => (
|
const Page: NextPage<Props> = props => {
|
||||||
<App
|
if (!props.data) {
|
||||||
menu={buildMenu(props.pageUrl, menuModel)}
|
console.log('kek error')
|
||||||
showAuthor={true}
|
return
|
||||||
menuPadding={true}
|
}
|
||||||
layout={'wide'}
|
|
||||||
>
|
|
||||||
<Head>
|
|
||||||
<title>{props.title}</title>
|
|
||||||
<Meta meta={props.meta} />
|
|
||||||
</Head>
|
|
||||||
|
|
||||||
{!props.image ? null : (
|
return (
|
||||||
<CollectiveImage
|
<App
|
||||||
data={props.image}
|
menu={buildMenu(props.pageUrl, menuModel)}
|
||||||
style={{
|
showAuthor={true}
|
||||||
marginBottom: 'var(--double-margin)',
|
menuPadding={true}
|
||||||
}}
|
layout={'wide'}
|
||||||
/>
|
>
|
||||||
)}
|
<Head>
|
||||||
|
<title>{props.title}</title>
|
||||||
|
<Meta meta={props.meta} />
|
||||||
|
</Head>
|
||||||
|
|
||||||
<CardList
|
{!props.image ? null : (
|
||||||
items={props.persons}
|
<CollectiveImage
|
||||||
renderItem={(person, index) => (
|
data={props.image}
|
||||||
<PersonCard
|
style={{
|
||||||
key={index}
|
marginBottom: 'var(--double-margin)',
|
||||||
profile={person}
|
}}
|
||||||
picture={person.picture}
|
|
||||||
url={person.url}
|
|
||||||
name={person.name}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
|
||||||
</App>
|
|
||||||
)
|
|
||||||
|
|
||||||
export const unstable_getServerProps = async (ctx: NextPageContext) => {
|
<CardList
|
||||||
const pageUrl = ctx.req.url
|
items={props.data}
|
||||||
|
renderItem={(person, index) => (
|
||||||
|
<PersonCard
|
||||||
|
key={index}
|
||||||
|
profile={person}
|
||||||
|
picture={person.picture}
|
||||||
|
url={person.url}
|
||||||
|
name={person.name}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</App>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticProps = async (ctx: NextPageContext) => {
|
||||||
|
// const pageUrl = ctx.req.url
|
||||||
|
const pageUrl = '/collective'
|
||||||
|
|
||||||
const res = await requestGet<IResponseItems<IPerson>>(createApiUrl('/api/persons'), { items: [] })
|
const res = await requestGet<IResponseItems<IPerson>>(createApiUrl('/api/persons'), { items: [] })
|
||||||
const persons = res.items || []
|
const data = res.items || []
|
||||||
const title = 'Преподаватели Шлиссельбургской ДХШ'
|
const title = 'Преподаватели Шлиссельбургской ДХШ'
|
||||||
const imageFile = 'Images/HudozkaCollective2017.jpg'
|
const imageFile = 'Images/HudozkaCollective2017.jpg'
|
||||||
const resImage = await requestGet(createApiUrl(`/api/image?file=${imageFile}`), null)
|
const resImage = await requestGet(createApiUrl(`/api/image?file=${imageFile}`), null)
|
||||||
@@ -72,7 +80,7 @@ export const unstable_getServerProps = async (ctx: NextPageContext) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
persons,
|
data,
|
||||||
image,
|
image,
|
||||||
pageUrl,
|
pageUrl,
|
||||||
title,
|
title,
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import Head from 'next/head'
|
|
||||||
import { App } from '../../src/components/App'
|
|
||||||
import Document from '../../src/components/Document'
|
|
||||||
import { Share } from '../../src/components/Share'
|
|
||||||
import menuModel from '../../src/models/menu'
|
|
||||||
import { buildMenu } from '../../src/lib/menu'
|
|
||||||
import { meta } from '../../src/lib/meta'
|
|
||||||
import { Meta } from '../../src/components/Meta'
|
|
||||||
import { createApiUrl, requestGet, wrapInitialProps } from '../../src/next-lib'
|
|
||||||
|
|
||||||
const Page = (props) => (
|
|
||||||
<App
|
|
||||||
menu={buildMenu(props.pageUrl, menuModel)}
|
|
||||||
showAuthor={true}
|
|
||||||
menuPadding={true}
|
|
||||||
layout={'wide'}
|
|
||||||
>
|
|
||||||
<Head>
|
|
||||||
<title>{props.file.title}</title>
|
|
||||||
<Meta meta={props.meta} />
|
|
||||||
</Head>
|
|
||||||
<Document {...props.file} />
|
|
||||||
<Share />
|
|
||||||
</App>
|
|
||||||
)
|
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
|
||||||
const pageUrl = '/documents'
|
|
||||||
const id = ctx.query.document
|
|
||||||
const file = await requestGet(createApiUrl(`/api/files/${id}`), {})
|
|
||||||
|
|
||||||
return {
|
|
||||||
file,
|
|
||||||
pageUrl,
|
|
||||||
meta: meta({
|
|
||||||
title: file.meta,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default Page
|
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import Head from 'next/head'
|
||||||
|
import { App } from 'src/components/App'
|
||||||
|
import Document from 'src/components/Document'
|
||||||
|
import { Share } from 'src/components/Share'
|
||||||
|
import menuModel from 'src/models/menu'
|
||||||
|
import { buildMenu } from 'src/lib/menu'
|
||||||
|
import { meta } from 'src/lib/meta'
|
||||||
|
import { Meta } from 'src/components/Meta'
|
||||||
|
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
||||||
|
import { NextPage } from 'next'
|
||||||
|
import { IMeta } from 'src/types'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
pageUrl: string
|
||||||
|
data: any //(file)
|
||||||
|
meta: IMeta
|
||||||
|
}
|
||||||
|
|
||||||
|
const Page: NextPage<Props> = props => {
|
||||||
|
if (!props.data) {
|
||||||
|
console.log('kek error', props)
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<App
|
||||||
|
menu={buildMenu(props.pageUrl, menuModel)}
|
||||||
|
showAuthor={true}
|
||||||
|
menuPadding={true}
|
||||||
|
layout={'wide'}
|
||||||
|
>
|
||||||
|
<Head>
|
||||||
|
<title>{props.data.title}</title>
|
||||||
|
<Meta meta={props.meta} />
|
||||||
|
</Head>
|
||||||
|
<Document {...props.data} />
|
||||||
|
<Share />
|
||||||
|
</App>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticProps = async (ctx: any) => {
|
||||||
|
const pageUrl = '/documents'
|
||||||
|
const id = ctx.params.slug
|
||||||
|
const data = await requestGet(createApiUrl(`/api/files/${id}`), {})
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
data,
|
||||||
|
pageUrl,
|
||||||
|
meta: meta({
|
||||||
|
// title: file.meta,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticPaths = async () => {
|
||||||
|
console.log('call file unstable_getStaticPaths')
|
||||||
|
|
||||||
|
const urls = await requestGet<IResponseItems<string>>(createApiUrl(`/api/files/urls`), null)
|
||||||
|
if (!urls) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
paths: urls.items
|
||||||
|
.map(x => x.replace('/document/', ''))
|
||||||
|
.map(slug => {
|
||||||
|
return {
|
||||||
|
params: {
|
||||||
|
slug,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Page
|
||||||
+20
-20
@@ -1,15 +1,13 @@
|
|||||||
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 menuModel from '../src/models/menu'
|
import menuModel from 'src/models/menu'
|
||||||
import { buildMenu } from '../src/lib/menu'
|
import { buildMenu } from 'src/lib/menu'
|
||||||
import { meta } from '../src/lib/meta'
|
import { meta } from 'src/lib/meta'
|
||||||
import { IDocument } from '../src/types'
|
import { IDocument } from 'src/types'
|
||||||
|
import { DocumentList } from 'src/components/DocumentList'
|
||||||
import { DocumentList } from '../src/components/DocumentList'
|
import { unique } from 'src/utils/common'
|
||||||
import { unique } from '../src/utils/common'
|
import { createApiUrl, requestGet, wrapInitialProps, IResponseItems } from 'src/next-lib'
|
||||||
import { createApiUrl, requestGet, wrapInitialProps, IResponseItems } from '../src/next-lib'
|
|
||||||
import { NextPage } from 'next'
|
import { NextPage } from 'next'
|
||||||
|
|
||||||
interface IDocumentCategory {
|
interface IDocumentCategory {
|
||||||
@@ -125,7 +123,7 @@ const Page: NextPage<IProps> = props => (
|
|||||||
</App>
|
</App>
|
||||||
)
|
)
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
export const unstable_getStaticProps = async (ctx) => {
|
||||||
const pageUrl = '/documents'
|
const pageUrl = '/documents'
|
||||||
const res = await requestGet<IResponseItems<IDocument>>(createApiUrl('/api/files'), { items: [] })
|
const res = await requestGet<IResponseItems<IDocument>>(createApiUrl('/api/files'), { items: [] })
|
||||||
const files = res.items
|
const files = res.items
|
||||||
@@ -133,14 +131,16 @@ Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
|||||||
const collections = getSorted(files)
|
const collections = getSorted(files)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
collections,
|
props: {
|
||||||
pageUrl,
|
collections,
|
||||||
title,
|
pageUrl,
|
||||||
meta: meta({
|
|
||||||
title,
|
title,
|
||||||
description: 'Документы Шлиссельбургской ДХШ',
|
meta: meta({
|
||||||
})
|
title,
|
||||||
|
description: 'Документы Шлиссельбургской ДХШ',
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
export default Page
|
export default Page
|
||||||
+16
-10
@@ -96,22 +96,28 @@ const Page: NextPage<IProps> = props => (
|
|||||||
</App>
|
</App>
|
||||||
)
|
)
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
export const unstable_getStaticProps = async (ctx: any) => {
|
||||||
const pageUrl = ctx.req.url
|
// const pageUrl = ctx.req.url
|
||||||
const res = await requestGet<any>(createApiUrl(`/api/albums`), {})
|
const pageUrl = '/gallery'
|
||||||
|
const res = await requestGet<any>(createApiUrl(`/api/albums`), null)
|
||||||
|
if (!res) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
const items = res.items || []
|
const items = res.items || []
|
||||||
const albumCollections = albumsByYear(items)
|
const albumCollections = albumsByYear(items)
|
||||||
const title = 'Галерея'
|
const title = 'Галерея'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
collections: [...albumCollections.entries()],
|
props: {
|
||||||
pageUrl,
|
collections: [...albumCollections.entries()],
|
||||||
title,
|
pageUrl,
|
||||||
meta: meta({
|
|
||||||
title,
|
title,
|
||||||
description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы'
|
meta: meta({
|
||||||
})
|
title,
|
||||||
|
description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы'
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
export default Page
|
export default Page
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import Head from 'next/head'
|
|
||||||
import { App } from '../src/components/App'
|
|
||||||
import { Schedule } from '../src/components/Schedule'
|
|
||||||
import { Share } from '../src/components/Share'
|
|
||||||
import menuModel from '../src/models/menu'
|
|
||||||
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}
|
|
||||||
layout={'wide'}
|
|
||||||
>
|
|
||||||
<Head>
|
|
||||||
<title>{props.title}</title>
|
|
||||||
</Head>
|
|
||||||
|
|
||||||
{/*<ScheduleList schedules={schedules}/>*/}
|
|
||||||
|
|
||||||
<Schedule {...props.schedule} />
|
|
||||||
|
|
||||||
<Share />
|
|
||||||
</App>
|
|
||||||
)
|
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
|
||||||
const pageUrl = ctx.req.url
|
|
||||||
const period = '2016-2017'
|
|
||||||
const semester = 'spring'
|
|
||||||
const schedule = await requestGet(createApiUrl(`/api/schedule?period=${period}&semester=${semester}`), {})
|
|
||||||
|
|
||||||
return {
|
|
||||||
schedule,
|
|
||||||
pageUrl,
|
|
||||||
title: 'Расписание',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default Page
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import Head from 'next/head'
|
||||||
|
import { App } from 'src/components/App'
|
||||||
|
import { Schedule } from 'src/components/Schedule'
|
||||||
|
import { Share } from 'src/components/Share'
|
||||||
|
import menuModel from 'src/models/menu'
|
||||||
|
import { buildMenu } from 'src/lib/menu'
|
||||||
|
import { createApiUrl, requestGet } from 'src/next-lib'
|
||||||
|
import { NextPage } from 'next'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
pageUrl: string
|
||||||
|
title: string
|
||||||
|
data: any //(schedule)
|
||||||
|
}
|
||||||
|
|
||||||
|
const Page: NextPage<Props> = props => (
|
||||||
|
<App
|
||||||
|
menu={buildMenu(props.pageUrl, menuModel)}
|
||||||
|
showAuthor={true}
|
||||||
|
menuPadding={true}
|
||||||
|
layout={'wide'}
|
||||||
|
>
|
||||||
|
<Head>
|
||||||
|
<title>{props.title}</title>
|
||||||
|
</Head>
|
||||||
|
|
||||||
|
{/*<ScheduleList schedules={schedules}/>*/}
|
||||||
|
|
||||||
|
<Schedule {...props.data} />
|
||||||
|
|
||||||
|
<Share />
|
||||||
|
</App>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const unstable_getStaticProps = async (ctx: any) => {
|
||||||
|
// const pageUrl = ctx.req.url
|
||||||
|
const pageUrl = '/schedule'
|
||||||
|
const period = '2016-2017'
|
||||||
|
const semester = 'spring'
|
||||||
|
const data = await requestGet(createApiUrl(`/api/schedule?period=${period}&semester=${semester}`), null)
|
||||||
|
if (!data) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
data,
|
||||||
|
pageUrl,
|
||||||
|
title: 'Расписание',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Page
|
||||||
Reference in new issue
Block a user