We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the dataBy... files inherit from the same function
const data = await getFreshDataBySlug(noteDir)
return data
}
https://github.com/JournalOfTrialAndError/centeroftrialanderror.com/blob/1c2a62be7e2ccb916db6dfb0a5f0c2701cee1fef/libs/scripts/src/lib/clone/mdxDataBySlug.mjs#L33
// @ts-check import { readFile, writeFile } from 'fs/promises' import { join } from 'path' import readdirp from 'readdirp' import { slugify } from './slug.mjs' export const getFreshDataBySlug = async (noteDir) => { const rawDir = await readdirp.promise(noteDir, { alwaysStat: true }) // Only include md(x) files return rawDir .filter((entry) => /\.mdx?$/.test(entry.path)) .reduce((acc, curr) => { const name = curr.basename.replace(/\.mdx?$/, '') const slug = slugify(name) const { atime, mtime, ctime, birthtime, ...stats } = { ...curr.stats } acc[slug] = { stats, fullPath: curr.fullPath, path: curr.path, name, slug, folders: curr.path .replace(curr.basename, '') .split('/') .filter((entry) => entry) ?? [], basename: curr.basename, } return acc }, {}) } // TODO: Make the dataBy... files inherit from the same function export const mdxDataBySlug = async (dataDir, noteDir) => { // if (process.env.ALWAYS_FRESH !== 'true' && process.env.NODE_ENV !== 'production') { // const data = await getFreshDataBySlug(noteDir) // return data // } const datapath = join(dataDir, 'dataBySlug.json') try { const data = JSON.parse(await readFile(datapath, 'utf8')) return data } catch (e) { console.log('No data found, writing new') const data = await getFreshDataBySlug(noteDir) await writeFile(datapath, JSON.stringify(data)) return data } }
6aed892d2c54468c663835105aef4d8ece8dab97
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Make the dataBy... files inherit from the same function
const data = await getFreshDataBySlug(noteDir)
return data
}
https://github.com/JournalOfTrialAndError/centeroftrialanderror.com/blob/1c2a62be7e2ccb916db6dfb0a5f0c2701cee1fef/libs/scripts/src/lib/clone/mdxDataBySlug.mjs#L33
6aed892d2c54468c663835105aef4d8ece8dab97
The text was updated successfully, but these errors were encountered: