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)
|
- [🍬 Typekit component](#-typekit-component)
|
||||||
- [✨ Development](#-development)
|
- [✨ Development](#-development)
|
||||||
- [🔮 Linting](#-linting)
|
- [🔮 Linting](#-linting)
|
||||||
- [🎈 Add a new project](#-add-a-new-project)
|
- [🎈 Add a new post](#-add-a-new-post)
|
||||||
- [🚚 Deployment](#-deployment)
|
- [🚚 Deployment](#-deployment)
|
||||||
- [🏛 Licenses](#-licenses)
|
- [🏛 Licenses](#-licenses)
|
||||||
- [Posts](#-posts)
|
- [Posts](#-posts)
|
||||||
@ -163,13 +163,14 @@ npm run format
|
|||||||
npm run format:css
|
npm run format:css
|
||||||
```
|
```
|
||||||
|
|
||||||
### 🎈 Add a new project
|
### 🎈 Add a new post
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run new "Hello"
|
npm run new "Hello World"
|
||||||
```
|
```
|
||||||
|
|
||||||
- [`scripts/new.js`](scripts/new.js)
|
- [`scripts/new.js`](scripts/new.js)
|
||||||
|
- [`scripts/new.md`](scripts/new.md)
|
||||||
|
|
||||||
## 🚚 Deployment
|
## 🚚 Deployment
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
"eslint-plugin-jsx-a11y": "^6.1.2",
|
"eslint-plugin-jsx-a11y": "^6.1.2",
|
||||||
"eslint-plugin-prettier": "^3.0.0",
|
"eslint-plugin-prettier": "^3.0.0",
|
||||||
"eslint-plugin-react": "^7.11.1",
|
"eslint-plugin-react": "^7.11.1",
|
||||||
|
"fs-extra": "^7.0.0",
|
||||||
"markdownlint": "^0.11.0",
|
"markdownlint": "^0.11.0",
|
||||||
"markdownlint-cli": "^0.13.0",
|
"markdownlint-cli": "^0.13.0",
|
||||||
"npm-run-all": "^4.1.3",
|
"npm-run-all": "^4.1.3",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs-extra'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
import ora from 'ora'
|
import ora from 'ora'
|
||||||
@ -21,12 +21,24 @@ const date = new Date().toISOString()
|
|||||||
const newContents = template
|
const newContents = template
|
||||||
.split('TITLE')
|
.split('TITLE')
|
||||||
.join(title)
|
.join(title)
|
||||||
|
.split('TITLE_SLUG')
|
||||||
|
.join(titleSlug)
|
||||||
.split('DATE')
|
.split('DATE')
|
||||||
.join(date)
|
.join(date)
|
||||||
|
|
||||||
const datePath = date.slice(0, 10)
|
const datePath = date.slice(0, 10)
|
||||||
|
const file = `${postsPath}/${datePath}-${titleSlug}/index.md`
|
||||||
|
|
||||||
fs.appendFile(`${postsPath}/${datePath}-${titleSlug}.md`, newContents, err => {
|
fs.outputFile(file, newContents)
|
||||||
if (err) spinner.fail(`Error creating post: ${err}`)
|
.then(() => fs.readFile(file, 'utf8'))
|
||||||
spinner.succeed(`New post '${title}' created.`)
|
.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
|
date: DATE
|
||||||
|
|
||||||
title: TITLE
|
title: TITLE
|
||||||
|
image: TITLE_SLUG-teaser.png
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- tag
|
- tag
|
||||||
|
Loading…
Reference in New Issue
Block a user