Skip to content

Commit f7eed9c

Browse files
committed
quick-start for new post.
1 parent 67828c1 commit f7eed9c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

create_post.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Get the current date
2+
$currentDate = Get-Date
3+
$year = $currentDate.Year
4+
$month = $currentDate.Month.ToString("D2")
5+
$day = $currentDate.Day.ToString("D2")
6+
7+
# Define the folder path
8+
$folderPath = "docs/posts/$year/$month/$day"
9+
10+
# Create the folder if it doesn't exist
11+
if (-Not (Test-Path -Path $folderPath)) {
12+
New-Item -ItemType Directory -Path $folderPath -Force | Out-Null
13+
}
14+
15+
# Define the file path
16+
$filePath = "$folderPath/index.md"
17+
18+
# Create the markdown file with YAML front matter
19+
$title = "Your Blog Post Title"
20+
$date = $currentDate.ToString("yyyy-MM-dd")
21+
22+
$yamlContent = @"
23+
---
24+
title: "$title"
25+
date: "$date"
26+
authors:
27+
-
28+
---
29+
"@
30+
31+
# Write the content to the file
32+
Set-Content -Path $filePath -Value $yamlContent
33+
34+
Write-Output "Blog post template created at $filePath"

0 commit comments

Comments
 (0)