Skip to content

Instantly share code, notes, and snippets.

@allpwrfulroot
Last active December 12, 2019 14:24
Show Gist options
  • Save allpwrfulroot/b741b18dd53645f9df679a23775bf958 to your computer and use it in GitHub Desktop.
Save allpwrfulroot/b741b18dd53645f9df679a23775bf958 to your computer and use it in GitHub Desktop.
API route that invokes the getMDXInfo utility for the 'projects' directory
import { getMDXInfo } from 'utils/get-meta'
export default async (req, res) => {
if (req.method !== 'GET') {
return (res.statusCode = 401)
}
res.setHeader('Content-Type', 'application/json')
try {
const { list } = await getMDXInfo('projects')
res.status(200).json({ projects: list })
} catch (error) {
res.status(400).json({ error })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment