-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jekyll-md): 新增生成带front matter的markdown文件命令
- Loading branch information
1 parent
ca606a6
commit a8b8f69
Showing
5 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const inquirer = require('inquirer'); | ||
const { fileGenerator } = require('../utils/file-generator'); | ||
const jekyllMD = async (title, category, tags) => { | ||
if (!(title && category && tags)) { | ||
const { inputTitle, inputCategory, inputTags } = await inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'inputTitle', | ||
message: '请输入标题', | ||
default: title || '', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'inputCategory', | ||
message: '请输入分类', | ||
default: category || '', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'inputTags', | ||
message: '请输入标签(用英文逗号分隔标签)', | ||
default: tags || '', | ||
}, | ||
]); | ||
title = inputTitle; | ||
category = inputCategory; | ||
tags = inputTags; | ||
} | ||
|
||
tags = tags.split(',').join(' '); | ||
fileGenerator({ | ||
templateName: 'jekyllMarkdown', | ||
option: { title, category, tags }, | ||
}); | ||
}; | ||
|
||
module.exports = { | ||
jekyllMD, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
layout: post | ||
title: <%- title %> | ||
author: Max | ||
categories: <%- category %> | ||
tags: <%- tags %> | ||
--- | ||
|
||
|
||
generated at <%- generatedAt %> by streakingman-cli@<%- version %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters