feat: add research submodule and page
This commit is contained in:
parent
3d450a389b
commit
4a39e535a3
13 changed files with 217 additions and 10 deletions
35
utils/getDocs.ts
Normal file
35
utils/getDocs.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import matter from 'gray-matter'
|
||||
|
||||
const docsDirectory = path.join(process.cwd(), 'research/docs')
|
||||
|
||||
export const getDocs = () => {
|
||||
const fileNames = fs.readdirSync(docsDirectory)
|
||||
return fileNames.map((fileName) => {
|
||||
|
||||
console.log("HERE", fileName)
|
||||
|
||||
if (!fileName || fileName.includes('README.md')) {
|
||||
return {
|
||||
id: 'readme',
|
||||
data: {},
|
||||
}
|
||||
}
|
||||
// set id and full path
|
||||
const id = fileName.replace(/\.md$/, '')
|
||||
const fullPath = path.join(docsDirectory, fileName)
|
||||
|
||||
// read file contents
|
||||
const fileContents = fs.readFileSync(fullPath, 'utf8')
|
||||
|
||||
// parse file contents
|
||||
const { data } = matter(fileContents)
|
||||
|
||||
// return id and data
|
||||
return {
|
||||
id,
|
||||
...data,
|
||||
}
|
||||
}) as any[]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue