import Head from 'next/head' import { App } from 'src/components/App' import { Meta } from 'src/components/Meta' import { splitBy } from 'src/lib/array' import { meta } from 'src/lib/meta' import { createApiUrl, requestGet } from 'src/next-lib' import { NextPage } from 'next' import { PageHeader } from 'src/components/PageHeader' const albumsByYear = splitBy(album => new Date(album.date).getFullYear()) function getMeta() { return { description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы' } } function resize(maxWidth, width, height) { const ratio = maxWidth / width return [ width * ratio, height * ratio, ] } const m = 1 const AlbumImage = ({ data, alt }) => { const [width, height] = resize(200, data.width, data.height) return ( {alt} `${url} ${density}x`)} /> ) } const GItem = ({ album }) => (
) const ACollection = ({ title, albums }) => (
{title}
{ albums.map((album, index) => ( )) }
) interface IProps { meta: any title: string collections: any[] } const Page: NextPage = props => ( {props.title} {props.collections.map(([year, albums], index) => ( ))} ) export const unstable_getStaticProps = async (ctx: any) => { // const pageUrl = ctx.req.url const res = await requestGet(createApiUrl(`/api/albums`), null) if (!res) { return null } const items = res.items || [] const albumCollections = albumsByYear(items) const title = 'Галерея' return { props: { collections: [...albumCollections.entries()], title, meta: meta({ title, description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы' }) } } } export default Page