1
0
mirror of synced 2025-12-22 03:16:52 -05:00
Files
docs/lib/layouts.js
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

19 lines
699 B
JavaScript

const fs = require('fs')
const path = require('path')
const walk = require('walk-sync').entries
const validLayoutExtensions = ['.md', '.html']
const layoutsDirectory = path.join(__dirname, '../layouts')
const layouts = {}
walk(layoutsDirectory, { directories: false })
.filter(entry => validLayoutExtensions.includes(path.extname(entry.relativePath)))
.filter(entry => !entry.relativePath.includes('README'))
.forEach(entry => {
const key = path.basename(entry.relativePath).split('.').slice(0, -1).join('.')
const fullPath = path.join(entry.basePath, entry.relativePath)
const content = fs.readFileSync(fullPath, 'utf8')
layouts[key] = content
})
module.exports = layouts