Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

layouts.js 699 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  1. const fs = require('fs')
  2. const path = require('path')
  3. const walk = require('walk-sync').entries
  4. const validLayoutExtensions = ['.md', '.html']
  5. const layoutsDirectory = path.join(__dirname, '../layouts')
  6. const layouts = {}
  7. walk(layoutsDirectory, { directories: false })
  8. .filter(entry => validLayoutExtensions.includes(path.extname(entry.relativePath)))
  9. .filter(entry => !entry.relativePath.includes('README'))
  10. .forEach(entry => {
  11. const key = path.basename(entry.relativePath).split('.').slice(0, -1).join('.')
  12. const fullPath = path.join(entry.basePath, entry.relativePath)
  13. const content = fs.readFileSync(fullPath, 'utf8')
  14. layouts[key] = content
  15. })
  16. module.exports = layouts
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...