collective page: display common page cards instead of person card
This commit is contained in:
1 parent
a3644c721b
commit
9cf7de825a
1 file changed
+33
-13
+33
-13
@@ -1,16 +1,32 @@
|
|||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import { get } from 'lodash'
|
|
||||||
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 { CollectiveImage } from 'src/components/CollectiveImage'
|
import { CollectiveImage } from 'src/components/CollectiveImage'
|
||||||
import { meta } from 'src/lib/meta'
|
import { meta } from 'src/lib/meta'
|
||||||
import { IMeta, Person } from 'src/types'
|
import { IMeta, IPage, ImageDefinition } from 'src/types'
|
||||||
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
import { createApiUrl, requestGet } from 'src/next-lib'
|
||||||
import { NextPage, NextPageContext } from 'next'
|
import { NextPage, NextPageContext } from 'next'
|
||||||
import { CardGrid } from 'src/components/CardGrid'
|
import { CardGrid } from 'src/components/CardGrid'
|
||||||
import { Card } from 'src/components/Card'
|
import { Card } from 'src/components/Card'
|
||||||
import { Block } from 'src/components/Block'
|
import { Block } from 'src/components/Block'
|
||||||
|
|
||||||
|
const persons = [
|
||||||
|
'/teacher/mg-timasheva',
|
||||||
|
'/teacher/va-sarzhin',
|
||||||
|
'/teacher/od-gogoleva',
|
||||||
|
'/teacher/nv-andreeva',
|
||||||
|
'/teacher/vv-voronova',
|
||||||
|
'/teacher/ea-burovtseva',
|
||||||
|
'/teacher/sa-latipova',
|
||||||
|
'/teacher/iv-khramov',
|
||||||
|
'/teacher/ma-khramova',
|
||||||
|
// АС Тимашева
|
||||||
|
// ЕЮ Тарасова
|
||||||
|
// ИН Втюрина
|
||||||
|
// МЮ Валькова
|
||||||
|
// РК Тимашев
|
||||||
|
]
|
||||||
|
|
||||||
type CardData = {
|
type CardData = {
|
||||||
title: string
|
title: string
|
||||||
caption?: string
|
caption?: string
|
||||||
@@ -83,25 +99,29 @@ const Page: NextPage<Props> = props => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const unstable_getStaticProps = async (ctx: NextPageContext) => {
|
export const unstable_getStaticProps = async (ctx: NextPageContext) => {
|
||||||
const res = await requestGet<IResponseItems<Person>>(createApiUrl('/api/persons'), null)
|
|
||||||
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<ImageDefinition>(createApiUrl(`/api/image?file=${imageFile}`), null)
|
||||||
const image = get(resImage, 'artifacts.large', null)
|
const image = resImage?.artifacts.large
|
||||||
const data: CardData[] = (res?.items || [])
|
|
||||||
|
const pages = await Promise.all(persons
|
||||||
|
.map(page => requestGet<IPage>(createApiUrl(`/api/page?page=${page}`), null))
|
||||||
|
)
|
||||||
|
const data: CardData[] = pages
|
||||||
|
.filter(Boolean)
|
||||||
.map(x => {
|
.map(x => {
|
||||||
const title = `${x.name[0]} ${x.name[1]} ${x.name[2]}`
|
const image = x.preview.artifacts.large
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
title: x.title,
|
||||||
caption: x.position,
|
caption: x.description,
|
||||||
href: x.url,
|
href: x.url,
|
||||||
imageSrc: x.picture.src,
|
imageSrc: image.src,
|
||||||
imageAlt: title,
|
imageAlt: title,
|
||||||
imageSrcSet: '',
|
imageSrcSet: image.set.join(' ')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
data,
|
data,
|
||||||
|
|||||||
Reference in new issue
Block a user