Coding is Life
Coding is Life

Reputation: 53

How to import/transfer md file to javascript string?

I'm curios is it possible to import md(mark down file) file in nodejs and use it as a string?

Question is very simple, how to use md file as a string in javascript (that's all)

Upvotes: 1

Views: 2626

Answers (1)

Coding is Life
Coding is Life

Reputation: 53

I found the solution. This way u can import md file and use it as a string

import {readFileSync} from 'fs'

const markdownContent = readFileSync('apps/express/netlify/CHANGELOG.md', 'utf-8')
console.log(markdownContent, '||1||')
console.log('|||||||')
console.log(JSON.stringify(console.log(markdownContent)), ' heeeere')

Upvotes: 1

Related Questions