Member/Ecology revamp.
This commit is contained in:
parent
fc7ec52574
commit
59d6e97787
31 changed files with 1763 additions and 1010 deletions
20
server/api/wiki/recent.get.js
Normal file
20
server/api/wiki/recent.get.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import WikiArticle from '../../models/wikiArticle.js'
|
||||
import { connectDB } from '../../utils/mongoose.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await connectDB()
|
||||
|
||||
const query = getQuery(event)
|
||||
const limit = Math.min(Math.max(parseInt(query.limit) || 4, 1), 10)
|
||||
|
||||
const articles = await WikiArticle.find({
|
||||
publishedAt: { $ne: null },
|
||||
hidden: { $ne: true }
|
||||
})
|
||||
.sort({ publishedAt: -1 })
|
||||
.limit(limit)
|
||||
.select('title url publishedAt')
|
||||
.lean()
|
||||
|
||||
return articles
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue