sort images better
This commit is contained in:
parent
5204131361
commit
146aaf867e
1 changed files with 17 additions and 10 deletions
|
|
@ -16,16 +16,23 @@ import Time from '../common/Time.js'
|
||||||
|
|
||||||
const log = logger('index.js')
|
const log = logger('index.js')
|
||||||
|
|
||||||
const allImages = () => [
|
const allImages = () => {
|
||||||
...fs.readdirSync('./../data/uploads/').map(f => ({
|
const images = fs.readdirSync('./../data/uploads/')
|
||||||
|
.map(f => ({
|
||||||
file: `./../data/uploads/${f}`,
|
file: `./../data/uploads/${f}`,
|
||||||
url: `/uploads/${f}`,
|
url: `/uploads/${f}`,
|
||||||
})),
|
}))
|
||||||
...fs.readdirSync('./../game/example-images/').map(f => ({
|
.sort((a, b) => {
|
||||||
|
return fs.statSync(b.file).mtime.getTime() -
|
||||||
|
fs.statSync(a.file).mtime.getTime()
|
||||||
|
})
|
||||||
|
const exampleImages = fs.readdirSync('./../game/example-images/')
|
||||||
|
.map(f => ({
|
||||||
file: `./../game/example-images/${f}`,
|
file: `./../game/example-images/${f}`,
|
||||||
url: `/example-images/${f}`,
|
url: `/example-images/${f}`,
|
||||||
})),
|
}))
|
||||||
]
|
return [...images, ...exampleImages]
|
||||||
|
}
|
||||||
|
|
||||||
const port = config.http.port
|
const port = config.http.port
|
||||||
const hostname = config.http.hostname
|
const hostname = config.http.hostname
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue