gallery refactoring
This commit is contained in:
1 parent
864d895105
commit
06b3f481bd
1 file changed
+1
-11
+1
-11
@@ -2,6 +2,7 @@ const React = require('react')
|
|||||||
const Article = require('../components/Article')
|
const Article = require('../components/Article')
|
||||||
const Album = require('../core/Album')
|
const Album = require('../core/Album')
|
||||||
const {render} = require('../lib/render')
|
const {render} = require('../lib/render')
|
||||||
|
const {splitBy} = require('../lib/array')
|
||||||
const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash
|
const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash
|
||||||
const {get} = require('koa-route')
|
const {get} = require('koa-route')
|
||||||
|
|
||||||
@@ -36,17 +37,6 @@ const ACollection = ({title, albums}) => (
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
function splitBy(key) {
|
|
||||||
return items => {
|
|
||||||
return items.reduce((acc, item) => {
|
|
||||||
const name = key(item)
|
|
||||||
const items = acc.get(name) || []
|
|
||||||
|
|
||||||
return acc.set(key(item), [...items, item])
|
|
||||||
}, new Map())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getGallery() {
|
function getGallery() {
|
||||||
return get('/gallery', async ctx => {
|
return get('/gallery', async ctx => {
|
||||||
const path = getPathWithNoTrailingSlash(ctx.path)
|
const path = getPathWithNoTrailingSlash(ctx.path)
|
||||||
|
|||||||
Reference in new issue
Block a user