Add '/slugs' route
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
index: async ctx => {
|
||||
const result = await strapi
|
||||
.query('teks')
|
||||
.model.find({})
|
||||
const sortedResult = result.sort((a, b) => {
|
||||
const aDate = new Date(a.published_at)
|
||||
const bDate = new Date(b.published_at)
|
||||
return bDate.getTime() - aDate.getTime()
|
||||
})
|
||||
ctx.send(sortedResult.map(({slug}) => slug));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user