Skip to content

Instantly share code, notes, and snippets.

@emmadesilva
Last active February 11, 2024 21:11
Show Gist options
  • Select an option

  • Save emmadesilva/b51d2daae1576cb08ff4c272bdeb55ce to your computer and use it in GitHub Desktop.

Select an option

Save emmadesilva/b51d2daae1576cb08ff4c272bdeb55ce to your computer and use it in GitHub Desktop.
Scaffold a bunch of Markdown blog posts
#!/bin/bash
for i in {1..25}
do
# Calculate the date in reverse order
reversed_date="2024-01-01 12:$(printf "%02d" $((25 - i)))"
# Create the file with the specified content
echo "---" > "_posts/post-$i.md"
echo "title: 'Post $i'" >> "_posts/post-$i.md"
echo "description: 'Post $i'" >> "_posts/post-$i.md"
echo "category: blog" >> "_posts/post-$i.md"
echo "author: default" >> "_posts/post-$i.md"
echo "date: '$reversed_date'" >> "_posts/post-$i.md"
echo "---" >> "_posts/post-$i.md"
echo "" >> "_posts/post-$i.md"
echo "## Write something awesome." >> "_posts/post-$i.md"
done
#!/bin/bash
for i in {1..25}
do
# Pad the variable $i with leading zeros for date formatting
padded_i=$(printf "%02d" $i)
# Create the file with the specified content
echo "---" > "_posts/post-$padded_i.md"
echo "title: 'Post $i'" >> "_posts/post-$padded_i.md"
echo "description: 'Post $i'" >> "_posts/post-$padded_i.md"
echo "category: blog" >> "_posts/post-$padded_i.md"
echo "author: default" >> "_posts/post-$padded_i.md"
echo "date: '2024-01-01 12:$padded_i'" >> "_posts/post-$padded_i.md"
echo "---" >> "_posts/post-$padded_i.md"
echo "" >> "_posts/post-$padded_i.md"
echo "## Write something awesome." >> "_posts/post-$padded_i.md"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment