Skip to content

Commit

Permalink
feat(css): use getFilesOfType for module recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
ovlb committed Mar 29, 2022
1 parent 63653c4 commit b256131
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions _src/_data/css.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
const path = require('path')
const fs = require('fs')
const { camelCase } = require('lodash')
const { compileCss } = require(path.join(
process.cwd(),
'_helper/compile-css.js',
))
const getFilesOfType = require(path.join(process.cwd(), '_helper/get-files.js'))
const STATIC_FOLDERS = require(path.join(process.cwd(), '_helper/paths.js'))

const cssPath = path.join(process.cwd(), STATIC_FOLDERS.css)

const partials = {}

fs.readdirSync(cssPath)
.filter((fileName) => fileName.endsWith('.css'))
.forEach(function (fileName) {
const property = camelCase(fileName.replace('.css', ''))
getFilesOfType(cssPath, '.css').forEach(function (fileName) {
const property = camelCase(fileName.replace('.css', ''))

Object.defineProperty(partials, property, {
value: fileName,
enumerable: true,
writable: true,
configurable: true,
})
Object.defineProperty(partials, property, {
value: fileName,
enumerable: true,
writable: true,
configurable: true,
})
})

module.exports = compileCss(partials)

0 comments on commit b256131

Please sign in to comment.