Skip to content

Commit f992021

Browse files
committed
improve script
1 parent 020be7b commit f992021

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

create_post.ps1

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55
# At the top of the file create a yaml block with title and date.
66

77
# I needed to unquote the date, and add the Out-Null to the New-Item command.
8+
# update... use the current date to get the next Tuesday, and create the folder for that date.
9+
810

911
# Get the current date
1012
$currentDate = Get-Date
11-
$year = $currentDate.Year
12-
$month = $currentDate.Month.ToString("D2")
13-
$day = $currentDate.Day.ToString("D2")
13+
# Calculate days to Tuesday (Tuesday is 2 in DayOfWeek enum, 0-6 for Sunday-Saturday)
14+
$daysToTuesday = (2 - [int]$currentDate.DayOfWeek + 7) % 7
15+
# If today is Tuesday, we want same day, so adjust if result is 7
16+
if ($daysToTuesday -eq 7) { $daysToTuesday = 0 }
17+
# Get Tuesday's date
18+
$tuesdayDate = $currentDate.AddDays($daysToTuesday)
19+
$year = $tuesdayDate.Year
20+
$month = $tuesdayDate.Month.ToString("D2")
21+
$day = $tuesdayDate.Day.ToString("D2")
22+
23+
1424

1525
# Define the folder path
1626
$folderPath = "docs/posts/$year/$month/$day"
@@ -25,15 +35,21 @@ $filePath = "$folderPath/index.md"
2535

2636
# Create the markdown file with YAML front matter
2737
$title = "Your Blog Post Title"
28-
$date = $currentDate.ToString("yyyy-MM-dd")
38+
$date = $tuesdayDate.ToString("yyyy-MM-dd")
2939

3040
$yamlContent = @"
3141
---
3242
title: "$title"
3343
date: $date
3444
authors:
35-
-
45+
- chris | norm | omar
3646
---
47+
48+
TOPIC_INTRODUCTION_HERE
49+
50+
Everyone and anyone are welcome to [join](https://weeklydevchat.com/join/) as long as you are kind, supportive, and respectful of others. Zoom link will be posted at 12pm MDT.
51+
52+
![alt text](${date}_image_filename.webp)
3753
"@
3854

3955
# Write the content to the file

0 commit comments

Comments
 (0)