[examples/data-literate][m]: factor our a working markdown+CSV (data literate) example from site (where we already had a demo).

* removed a few extraneous things
* added the README.md with some instructions
This commit is contained in:
Rufus Pollock
2022-02-21 12:25:46 +01:00
parent 99c5e358a1
commit 3a0f4e7b96
22 changed files with 5817 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
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))