mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 09:56:51 +01:00
Matthias Kretschmann
05ad0470c2
* migrate to biome * cleanup * fix * use tsx * script tweaks * fix test runs * path tweaks
27 lines
784 B
TypeScript
27 lines
784 B
TypeScript
import path from 'node:path'
|
|
import ora from 'ora'
|
|
import { createArticlePost } from './createArticlePost.js'
|
|
import { createPhotoPost } from './createPhotoPost.js'
|
|
|
|
const postsPath = path.join('.', 'content', 'articles')
|
|
const photosPath = path.join('.', 'content', 'photos')
|
|
const spinner = ora('Adding new post').start()
|
|
|
|
if (!process.argv[2]) {
|
|
spinner.fail(
|
|
'Use the format `npm run new "Title of post"` or `npm run new photo path/to/photo.jpg`'
|
|
)
|
|
}
|
|
|
|
const isPhoto = process.argv[2] === 'photo'
|
|
|
|
if (isPhoto) {
|
|
const photo = process.argv[3]
|
|
const photoTitle = process.argv[4]
|
|
createPhotoPost(photosPath, spinner, photo, photoTitle)
|
|
} else {
|
|
const title = process.argv[2]
|
|
const newDate = process.argv[3]
|
|
createArticlePost(postsPath, spinner, title, newDate)
|
|
}
|