datahub/site/lib/mdxUtils.js
Rufus Pollock 8c3b1bccd3 [site,#572][l]: merge in data literate material.
* Nav bar and layout
* Main catch all route that loads material from content
* Data Literate: demo plus all associated components
  * content/data-literate/demo.mdx
  * components/* (pretty much all are related to demo)
  * lib/markdown.js, lib/mdxUtils.js
  * api/proxy.js to proxy remote urls (to handle CORs)
  * content/data-literate.md (DL home page - old data literate home page converted to markdown)
* excel-viewer.js: excel viewer demo from data literate
* package.json / yarn.lock
  * Nav: @headlessui/react @heroicons/react/outline @heroicons/react
  * CSV support for table: papaparse
  * Excel support for tables etc: xlsx
  * Vega: react-vega vega vega-lite
  * MDX: next-mdx-remote (yarn rm @next/mdx)
2021-07-28 23:16:42 +02:00

24 lines
733 B
JavaScript

import fs from 'fs'
import glob from 'glob'
import path from 'path'
// POSTS_PATH is useful when you want to get the path to a specific file
export const POSTS_PATH = path.join(process.cwd(), 'content')
const walkSync = (dir, filelist = []) => {
fs.readdirSync(dir).forEach(file => {
filelist = fs.statSync(path.join(dir, file)).isDirectory()
? walkSync(path.join(dir, file), filelist)
: filelist.concat(path.join(dir, file))
})
return filelist
}
// postFilePaths is the list of all mdx files inside the POSTS_PATH directory
export const postFilePaths = walkSync(POSTS_PATH)
.map((file) => { return file.slice(POSTS_PATH.length) })
// Only include md(x) files
.filter((path) => /\.mdx?$/.test(path))