import React from 'react' import Head from 'next/head' import { App } from '../src/components/App' // import Album from '../src/components/Album' import Article from '../src/components/Article' import { Meta } from '../src/components/Meta' import menuModel from '../src/models/menu' import { buildMenu } from '../src/lib/menu' import { splitBy } from '../src/lib/array' import { meta } from '../src/lib/meta' import { createApiUrl, requestGet, wrapInitialProps } from '../src/next-lib' const albumsByYear = splitBy(album => new Date(album.date).getFullYear()) function getMeta() { return { description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы' } } const m = 1 const AlbumImage = ({ data, alt }) => ( {alt} `${url} ${density}x`)} /> ) const GItem = ({ album }) => (
) const ACollection = ({ title, albums }) => (
{title}
{ albums.map((album, index) => ( )) }
) const Page = (props) => ( {props.title}
{props.collections.map(([year, albums], index) => ( )) }
) Page.getInitialProps = wrapInitialProps(async (ctx) => { const pageUrl = ctx.req.url const res = await requestGet(createApiUrl(ctx.req, `/api/albums`), {}) const items = res.items || [] const albumCollections = albumsByYear(items) const title = 'Галерея' return { collections: [...albumCollections.entries()], pageUrl, title, meta: meta({ title, description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы' }) } }) export default Page