File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { writeFileSync } from "fs" ;
2+ import { join } from "path" ;
3+
4+ const [ slug ] = process . argv . slice ( 2 ) ;
5+
6+ if ( ! slug ) {
7+ console . error ( "Usage: node new-post.mjs <post-slug>" ) ;
8+ process . exit ( 1 ) ;
9+ }
10+
11+ const now = new Date ( ) ;
12+ const date = now . toISOString ( ) . replace ( / \. \d { 3 } Z $ / , "Z" ) ;
13+
14+ const filepath = join ( "src" , "blog" , `${ slug } .md` ) ;
15+
16+ const content = `---
17+ title:
18+ date: ${ date }
19+ description:
20+ tags: []
21+ ---
22+ ` ;
23+
24+ writeFileSync ( filepath , content ) ;
25+ console . log ( `Created ${ filepath } ` ) ;
Original file line number Diff line number Diff line change 66 "type" : " promptString" ,
77 "description" : " Post slug (e.g. my-post-title)"
88 },
9+ {
10+ "id" : " newPostSlug" ,
11+ "type" : " promptString" ,
12+ "description" : " Post slug (e.g. my-post-title)"
13+ },
914 {
1015 "id" : " authorName" ,
1116 "type" : " promptString" ,
1217 "description" : " Your name (e.g. John Doe)"
1318 }
1419 ],
1520 "tasks" : [
21+ {
22+ "label" : " New Post" ,
23+ "type" : " shell" ,
24+ "command" : " node .vscode/new-post.mjs \" ${input:newPostSlug}\" " ,
25+ "presentation" : {
26+ "reveal" : " always" ,
27+ "panel" : " shared"
28+ },
29+ "problemMatcher" : []
30+ },
1631 {
1732 "label" : " New Comment" ,
1833 "type" : " shell" ,
You can’t perform that action at this time.
0 commit comments