mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 03:32:51 +02:00
✨ feat: add format-posts srcipt
This commit is contained in:
parent
4d1e5b3054
commit
5ec894cd36
20 changed files with 232 additions and 89 deletions
|
@ -1,16 +1,20 @@
|
|||
/**
|
||||
* Create a new post with frontmatter
|
||||
* Usage: pnpm new-post <title>
|
||||
*
|
||||
* Example: pnpm new-post
|
||||
* Example: pnpm new-post first-post
|
||||
* Example: pnpm new-post first-post.md
|
||||
* Example: pnpm new-post first-post.mdx
|
||||
* Example: pnpm new-post 2025/03/first-post
|
||||
* Example: pnpm new-post 2025/03/first-post.md
|
||||
* Example: pnpm new-post 2025/03/first-post.mdx
|
||||
*/
|
||||
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
|
||||
import { basename, dirname, extname, join } from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { themeConfig } from '../src/config'
|
||||
|
||||
// pnpm new-post
|
||||
// pnpm new-post first-post
|
||||
// pnpm new-post first-post.md
|
||||
// pnpm new-post first-post.mdx
|
||||
// pnpm new-post 2025/03/first-post
|
||||
// pnpm new-post 2025/03/first-post.md
|
||||
// pnpm new-post 2025/03/first-post.mdx
|
||||
|
||||
// Process file path
|
||||
const rawPath = process.argv[2] || 'new-post'
|
||||
const baseName = basename(rawPath).replace(/\.(md|mdx)$/, '')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue