collective page card style changed; pass common card data to grid
This commit is contained in:
1 parent
cdeece2b0b
commit
76e7a7e9bb
1 file changed
+39
-24
+39
-24
@@ -4,24 +4,27 @@ 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, IImage } from 'src/types'
|
import { IMeta, Person } from 'src/types'
|
||||||
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
import { createApiUrl, requestGet, IResponseItems } 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'
|
||||||
|
|
||||||
interface IPerson {
|
type CardData = {
|
||||||
url: string
|
title: string
|
||||||
name: string
|
caption?: string
|
||||||
position: string
|
imageSrc: string
|
||||||
picture: IImage
|
imageAlt: string
|
||||||
|
imageSrcSet: string
|
||||||
|
href: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string
|
title: string
|
||||||
image: string
|
image: string
|
||||||
meta: IMeta
|
meta: IMeta
|
||||||
data: IPerson[]
|
data: CardData[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Page: NextPage<Props> = props => {
|
const Page: NextPage<Props> = props => {
|
||||||
@@ -52,24 +55,26 @@ const Page: NextPage<Props> = props => {
|
|||||||
<CardGrid style={{
|
<CardGrid style={{
|
||||||
marginBottom: 'var(--size-xl)',
|
marginBottom: 'var(--size-xl)',
|
||||||
}}>
|
}}>
|
||||||
{props.data.map((item, index) => (
|
{props.data.map(item => (
|
||||||
<Card
|
<Card
|
||||||
key={index}
|
key={item.href}
|
||||||
layout={'featured'}
|
layout={'featured'}
|
||||||
img={{
|
img={{
|
||||||
src: item.picture.src,
|
src: item.imageSrc,
|
||||||
alt: item.name,
|
alt: item.imageAlt,
|
||||||
srcSet: '',//item.name.sr,
|
srcSet: item.imageSrcSet,
|
||||||
}}
|
}}
|
||||||
href={item.url}
|
href={item.href}
|
||||||
>
|
>
|
||||||
<h2 style={{
|
<Block direction={'vertical'}>
|
||||||
margin: '0 0 var(--size-s)',
|
<span>{item.title}</span>
|
||||||
fontSize: '14pt',
|
<span style={{
|
||||||
}}>
|
paddingTop: 'var(--size-s)',
|
||||||
{item.name[0]} {item.name[1]} {item.name[2]}
|
fontSize: 'var(--font-size-second)',
|
||||||
</h2>
|
}}>
|
||||||
{item.position}
|
{item.caption}
|
||||||
|
</span>
|
||||||
|
</Block>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
</CardGrid>
|
</CardGrid>
|
||||||
@@ -78,14 +83,24 @@ const Page: NextPage<Props> = props => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const unstable_getStaticProps = async (ctx: NextPageContext) => {
|
export const unstable_getStaticProps = async (ctx: NextPageContext) => {
|
||||||
// const pageUrl = ctx.req.url
|
const res = await requestGet<IResponseItems<Person>>(createApiUrl('/api/persons'), null)
|
||||||
|
|
||||||
const res = await requestGet<IResponseItems<IPerson>>(createApiUrl('/api/persons'), null)
|
|
||||||
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)
|
||||||
const image = get(resImage, 'artifacts.large', null)
|
const image = get(resImage, 'artifacts.large', null)
|
||||||
|
const data: CardData[] = (res?.items || [])
|
||||||
|
.map(x => {
|
||||||
|
const title = `${x.name[0]} ${x.name[1]} ${x.name[2]}`
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
caption: x.position,
|
||||||
|
href: x.url,
|
||||||
|
imageSrc: x.picture.src,
|
||||||
|
imageAlt: title,
|
||||||
|
imageSrcSet: '',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
Reference in new issue
Block a user