Skip to content

Commit

Permalink
feat: expose packages through api (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barbapapazes authored Nov 24, 2023
1 parent 3e576c8 commit c8ada8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default defineNuxtConfig({
prerender: {
failOnError: false,
crawlLinks: true,
routes: ['/', '/blog', '/packages', '/api/search.txt', '/rss.xml', '/rss.xml', '/blog/rss.xml', '/learn/rss.xml', '/explore/rss.xml', '/build/rss.xml', '/robots.txt', '/sitemap.xml'],
routes: ['/', '/blog', '/packages', '/api/search.txt', '/api/content/packages.json', '/rss.xml', '/rss.xml', '/blog/rss.xml', '/learn/rss.xml', '/explore/rss.xml', '/build/rss.xml', '/robots.txt', '/sitemap.xml'],
},
routeRules: {
'/api/github/**': {
Expand Down
15 changes: 15 additions & 0 deletions server/api/content/packages.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { serverQueryContent } from '#content/server'

export default defineEventHandler(async (event) => {
const packages = await serverQueryContent(event).where({ _path: /^\/packages\// }).find()

return packages.map((pkg) => {
return {
title: pkg.title,
description: pkg.description,
path: pkg._path,
url: `https://unjs.io${pkg._path}`,
npm: pkg.npm,
}
})
})

0 comments on commit c8ada8f

Please sign in to comment.