quickbuild
Version:
A mature, feature-complete application generator with an emphasis on speed
20 lines (16 loc) • 664 B
JavaScript
const fs = require('fs')
const path = require('path')
const codeBlocksWithPaths = document.querySelectorAll('code[data-path]')
Array.prototype.forEach.call(codeBlocksWithPaths, (code) => {
const codePath = path.join(__dirname, '..', code.dataset.path)
const extension = path.extname(codePath)
code.classList.add(`language-${extension.substring(1)}`)
code.textContent = fs.readFileSync(codePath)
})
document.addEventListener('DOMContentLoaded', () => {
const highlight = require('highlight.js')
const codeBlocks = document.querySelectorAll('pre code')
Array.prototype.forEach.call(codeBlocks, (code) => {
highlight.highlightBlock(code)
})
})