Add new blog script creation script
This commit is contained in:
parent
cbd2872f9f
commit
cb2aa96e90
2 changed files with 38 additions and 2 deletions
35
create-blog-post.sh
Executable file
35
create-blog-post.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
check_existing_file() {
|
||||||
|
if [ -e "$1/$2.md" ]; then
|
||||||
|
echo "Error: A file with the name '$2.md' already exists in the '$1' directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
read -p "Enter the title for the new blog post: " title
|
||||||
|
kebab_title=$(echo "$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||||
|
|
||||||
|
check_existing_file "src/blog" "$kebab_title"
|
||||||
|
check_existing_file "src/feed" "$kebab_title"
|
||||||
|
|
||||||
|
# Create a new blog post file with the appropriate frontmatter and content
|
||||||
|
echo "---" > "src/blog/$kebab_title.md"
|
||||||
|
echo "title: $title" >> "src/blog/$kebab_title.md"
|
||||||
|
echo "layout: article.njk" >> "src/blog/$kebab_title.md"
|
||||||
|
echo "date: git Last Modified" >> "src/blog/$kebab_title.md"
|
||||||
|
echo "tags: post" >> "src/blog/$kebab_title.md"
|
||||||
|
echo "excerpt: Placeholder text for excerpt" >> "src/blog/$kebab_title.md"
|
||||||
|
echo "---" >> "src/blog/$kebab_title.md"
|
||||||
|
echo -e "\nThis is the content of the new blog post." >> "src/blog/$kebab_title.md"
|
||||||
|
|
||||||
|
# Create a new feed file with the appropriate frontmatter
|
||||||
|
echo "---" > "src/feed/$kebab_title.md"
|
||||||
|
echo "title: $title" >> "src/feed/$kebab_title.md"
|
||||||
|
echo "relativeUrl: /blog/$kebab_title" >> "src/feed/$kebab_title.md"
|
||||||
|
echo "date: git Created" >> "src/feed/$kebab_title.md"
|
||||||
|
echo "tags: feed" >> "src/feed/$kebab_title.md"
|
||||||
|
echo "---" >> "src/feed/$kebab_title.md"
|
||||||
|
echo -e "\nThis is the content of the new blog post." >> "src/feed/$kebab_title.md"
|
||||||
|
|
||||||
|
$EDITOR "src/blog/$kebab_title.md"
|
||||||
|
|
@ -4,12 +4,13 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
|
||||||
"start": "npx @11ty/eleventy --serve",
|
"start": "npx @11ty/eleventy --serve",
|
||||||
|
"createBlogPost": "bash create-blog-post.sh",
|
||||||
"build": "npx @11ty/eleventy",
|
"build": "npx @11ty/eleventy",
|
||||||
"deploy": "netlify deploy --build",
|
"deploy": "netlify deploy --build",
|
||||||
"deploy:prod": "netlify deploy --prod --build",
|
"deploy:prod": "netlify deploy --prod --build",
|
||||||
"postdeploy:prod": "webmention dist/feed.xml --send"
|
"postdeploy:prod": "webmention dist/feed.xml --send",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue