-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateBlog.js
More file actions
45 lines (30 loc) · 792 Bytes
/
Copy pathcreateBlog.js
File metadata and controls
45 lines (30 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const path = require('path')
const fs = require('fs')
const blogName = process.argv[2]
const blogPath = path.resolve(__dirname, 'content/blog')
const MARKDOWN_FILE_NAME = 'index.md'
const date = new Date().toISOString()
const header = `---
title: ${blogName.replace(/-/g, ' ')}
date: ${date}
type: html
action: copy
---
`
const body = `
#### Listen to this post!
<audio controls="controls">
<source type="audio/mp3" src="${blogName}.mp3"></source>
</audio>
<hr />
### Introduction
Some cool text here!
`
const output = header.concat(body)
const outputPath = `${blogPath}/${blogName}`
// make folder
fs.mkdirSync(outputPath)
// make index.md file with content
const outputFilePath = `${outputPath}/${MARKDOWN_FILE_NAME}`
// write file
fs.writeFileSync(outputFilePath, output)