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 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')
|
||||
|
||||
@@ -36,17 +37,6 @@ const ACollection = ({title, albums}) => (
|
||||
</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() {
|
||||
return get('/gallery', async ctx => {
|
||||
const path = getPathWithNoTrailingSlash(ctx.path)
|
||||
|
||||
Reference in new issue
Block a user