Skip to content

Commit

Permalink
Create getAllIdeas2023.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jddeep authored Feb 13, 2025
1 parent b5b9101 commit d29959b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/helper/getAllIdeas2023.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import glob from 'fast-glob'
import * as path from 'path'

async function importIdea(ideaFilename) {
let { meta, default: component } = await import(
`../pages/ideas/2023/${ideaFilename}`
)
return {
slug: ideaFilename.replace(/(\/index)?\.mdx$/, ''),
...meta,
component,
}
}

export async function getAllIdeas() {
let ideaFilenames = await glob(['*.mdx','*/index.mdx'], {
cwd: path.join(process.cwd(), 'src/pages/ideas/2023'),
})

let ideas = await Promise.all(ideaFilenames.map(importIdea))

return ideas
}

0 comments on commit d29959b

Please sign in to comment.