Merge branch 'worktree-agent-ac00ecc9'

This commit is contained in:
Jennie Robinson Faber 2026-04-09 22:38:36 +01:00
commit 20c961113d
2 changed files with 197 additions and 0 deletions

View file

@ -0,0 +1,32 @@
import WikiArticle from '../../models/wikiArticle.js'
import { connectDB } from '../../utils/mongoose.js'
import { requireAuth } from '../../utils/auth.js'
export default defineEventHandler(async (event) => {
const member = await requireAuth(event)
// Combine craft tags and cooperative ecology tags
const craftTags = member.craftTags || []
const ecologyTags = (member.communityEcology?.topics || []).map(t => t.tagSlug)
const memberTags = [...new Set([...craftTags, ...ecologyTags].filter(Boolean))]
if (!memberTags.length) {
return []
}
await connectDB()
const query = getQuery(event)
const limit = Math.min(Math.max(parseInt(query.limit) || 10, 1), 25)
const articles = await WikiArticle.find({
tags: { $in: memberTags },
publishedAt: { $ne: null }
})
.sort({ publishedAt: -1 })
.limit(limit)
.select('title url summary tags collection publishedAt')
.lean()
return articles
})