This commit is contained in:
Artur Gurgul 2024-10-17 23:51:03 +02:00
parent d086c1d493
commit 0f1d41a991
30 changed files with 1013 additions and 1536 deletions

View file

@ -1,7 +1,9 @@
const hljs = require('highlight.js')
const { marked } = require('marked')
const { markedHighlight } = require('marked-highlight')
const matter = require('gray-matter')
import hljs from 'highlight.js'
import { marked } from 'marked'
import { markedHighlight } from 'marked-highlight'
import matter from 'gray-matter'
import fs from 'fs'
import path from 'path'
marked.use(markedHighlight({
langPrefix: 'hljs language-',
@ -11,7 +13,7 @@ marked.use(markedHighlight({
}
}))
function parseMD(file) {
export function parseMD(file) {
const fileContents = fs.readFileSync(path.join("./", file), 'utf8')
@ -25,13 +27,13 @@ function parseMD(file) {
}
}
const renderer = new marked.Renderer();
const renderer = new marked.Renderer()
renderer.paragraph = (text) => {
return text.text
}
function parseMarkdown(obj) {
export function parseMarkdown(obj) {
for (let key in obj) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
if (Array.isArray(obj[key])) {