const React = require('react')
const Article = require('../components/Article')
const Album = require('../core/Album')
const {render} = require('../lib/render')
const {splitBy} = require('../lib/array')
const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash
const {get} = require('koa-route')
function getMeta() {
return {
title: 'Галерея',
description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы'
}
}
// {data.set.map((s, i) => (
//
// ))}
// const m = 0.5
const m = 1
const AlbumImage = ({data, alt}) => (
`${url} ${density}x`)}
/>
)
const GItem = ({album}) => (
)
const ACollection = ({title, albums}) => (
{title}
{
albums.map((album, index) => (
))
}
)
function getGallery() {
return get('/gallery', async ctx => {
const path = getPathWithNoTrailingSlash(ctx.path)
const query = {}
const albums = await Album.find(query, {sort: {date: -1}})
if (albums.length) {
const meta = getMeta()
const albumsByYear = splitBy(a => a.date.getFullYear())(albums)
const Component = (
{
[...albumsByYear.entries()].map(([year, albums], index) => (
))
}
)
ctx.type = 'text/html'
ctx.body = await render(path, Component, getMeta(), {menuPadding: true})
} else {
ctx.status = 404
}
})
}
exports.getGallery = getGallery