mirror of
https://github.com/BillyOutlast/posthog.com.git
synced 2026-02-04 03:11:21 +01:00
Build clean up (#7788)
* clean up some build errors * removed unused shortcodes * remove import gen script * dont source non-team member profiles
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const baseDir = './src/components'
|
||||
const mdxIgnore = fs.readFileSync(path.join(baseDir, './.mdxignore'), 'utf8')
|
||||
const componentsToIgnore = new Set(mdxIgnore.split('\n'))
|
||||
|
||||
const getComponentsInDir = (dir, components = []) => {
|
||||
const dirContents = fs.readdirSync(dir)
|
||||
let subdirectories = []
|
||||
let indexFileInDir = false
|
||||
for (let f of dirContents) {
|
||||
if (fs.lstatSync(`${dir}/${f}`).isDirectory() && !componentsToIgnore.has(f)) {
|
||||
subdirectories.push(f)
|
||||
continue
|
||||
}
|
||||
if (!indexFileInDir && f.includes('index') && !f.includes('css')) {
|
||||
indexFileInDir = true
|
||||
}
|
||||
}
|
||||
if (!subdirectories || indexFileInDir) {
|
||||
return [...components, dir]
|
||||
}
|
||||
for (let subdir of subdirectories) {
|
||||
components = getComponentsInDir(`${dir}/${subdir}`, components)
|
||||
}
|
||||
return components
|
||||
}
|
||||
|
||||
const generateFile = () => {
|
||||
let imports = '// AUTO GENERATED FILE \n\n'
|
||||
let componentNames = []
|
||||
for (let component of getComponentsInDir(baseDir)) {
|
||||
const destructuredPath = component.split('/')
|
||||
const relativePath = './' + destructuredPath.slice(2).join('/')
|
||||
const componentName = destructuredPath[destructuredPath.length - 1]
|
||||
imports += `import { ${componentName} } from '${relativePath}'\n`
|
||||
componentNames.push(componentName)
|
||||
}
|
||||
imports += '\nexport const shortcodes = {\n\t' + componentNames.join(',\n\t') + '\n}'
|
||||
fs.writeFileSync('./src/mdxGlobalComponents.js', imports)
|
||||
}
|
||||
|
||||
generateFile()
|
||||
Reference in New Issue
Block a user