mirror of
https://github.com/kremalicious/blog.git
synced 2025-01-03 18:35:07 +01:00
switch to folder posts by default
This commit is contained in:
parent
2476b1507c
commit
0daf09285a
@ -27,7 +27,7 @@
|
||||
- [🍬 Typekit component](#-typekit-component)
|
||||
- [✨ Development](#-development)
|
||||
- [🔮 Linting](#-linting)
|
||||
- [🎈 Add a new project](#-add-a-new-project)
|
||||
- [🎈 Add a new post](#-add-a-new-post)
|
||||
- [🚚 Deployment](#-deployment)
|
||||
- [🏛 Licenses](#-licenses)
|
||||
- [Posts](#-posts)
|
||||
@ -163,13 +163,14 @@ npm run format
|
||||
npm run format:css
|
||||
```
|
||||
|
||||
### 🎈 Add a new project
|
||||
### 🎈 Add a new post
|
||||
|
||||
```bash
|
||||
npm run new "Hello"
|
||||
npm run new "Hello World"
|
||||
```
|
||||
|
||||
- [`scripts/new.js`](scripts/new.js)
|
||||
- [`scripts/new.md`](scripts/new.md)
|
||||
|
||||
## 🚚 Deployment
|
||||
|
||||
|
@ -87,6 +87,7 @@
|
||||
"eslint-plugin-jsx-a11y": "^6.1.2",
|
||||
"eslint-plugin-prettier": "^3.0.0",
|
||||
"eslint-plugin-react": "^7.11.1",
|
||||
"fs-extra": "^7.0.0",
|
||||
"markdownlint": "^0.11.0",
|
||||
"markdownlint-cli": "^0.13.0",
|
||||
"npm-run-all": "^4.1.3",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fs from 'fs'
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
import slugify from 'slugify'
|
||||
import ora from 'ora'
|
||||
@ -21,12 +21,24 @@ const date = new Date().toISOString()
|
||||
const newContents = template
|
||||
.split('TITLE')
|
||||
.join(title)
|
||||
.split('TITLE_SLUG')
|
||||
.join(titleSlug)
|
||||
.split('DATE')
|
||||
.join(date)
|
||||
|
||||
const datePath = date.slice(0, 10)
|
||||
const file = `${postsPath}/${datePath}-${titleSlug}/index.md`
|
||||
|
||||
fs.appendFile(`${postsPath}/${datePath}-${titleSlug}.md`, newContents, err => {
|
||||
if (err) spinner.fail(`Error creating post: ${err}`)
|
||||
fs.outputFile(file, newContents)
|
||||
.then(() => fs.readFile(file, 'utf8'))
|
||||
.then(() => {
|
||||
spinner.succeed(`New post '${title}' created.`)
|
||||
})
|
||||
.catch(err => {
|
||||
spinner.fail(`Error creating post: ${err}`)
|
||||
})
|
||||
|
||||
// fs.appendFile(`${postsPath}/${datePath}-${titleSlug}.md`, newContents, err => {
|
||||
// if (err) spinner.fail(`Error creating post: ${err}`)
|
||||
// spinner.succeed(`New post '${title}' created.`)
|
||||
// })
|
||||
|
@ -3,6 +3,7 @@ type: post
|
||||
date: DATE
|
||||
|
||||
title: TITLE
|
||||
image: TITLE_SLUG-teaser.png
|
||||
|
||||
tags:
|
||||
- tag
|
||||
|
Loading…
Reference in New Issue
Block a user