mirror of
https://github.com/peter-tanner/peter-tanner.github.io.git
synced 2024-11-30 12:00:18 +08:00
autogenerate image dir
This commit is contained in:
parent
85ccd5c828
commit
871de43c9e
7
post.sh
7
post.sh
|
@ -27,8 +27,8 @@ sanitized_title=$(sanitize_title "$user_title")
|
||||||
|
|
||||||
# Generate the filename with the current date
|
# Generate the filename with the current date
|
||||||
current_date=$(date +'%Y-%m-%d')
|
current_date=$(date +'%Y-%m-%d')
|
||||||
filename="${current_date}-${sanitized_title}.md"
|
filename="${current_date}-${sanitized_title}"
|
||||||
filepath="_posts/${filename}"
|
filepath="_posts/${filename}.md"
|
||||||
|
|
||||||
# Check if the file already exists
|
# Check if the file already exists
|
||||||
if [ -e "$filepath" ]; then
|
if [ -e "$filepath" ]; then
|
||||||
|
@ -36,5 +36,6 @@ if [ -e "$filepath" ]; then
|
||||||
else
|
else
|
||||||
# Create the new file and add the front matter
|
# Create the new file and add the front matter
|
||||||
generate_front_matter "$user_title" > "$filepath"
|
generate_front_matter "$user_title" > "$filepath"
|
||||||
echo "File '$filename' created successfully in the '_posts' subdirectory."
|
mkdir -p "assets/img/${filename}"
|
||||||
|
echo "File '$filename.md' created successfully in the '_posts' subdirectory."
|
||||||
fi
|
fi
|
||||||
|
|
12
push.sh
12
push.sh
|
@ -11,14 +11,20 @@ generate_commit_message() {
|
||||||
}
|
}
|
||||||
|
|
||||||
commit_msg="$(generate_commit_message)"
|
commit_msg="$(generate_commit_message)"
|
||||||
|
new_posts="$(get_new_posts)"
|
||||||
|
|
||||||
# Check if there are any new or modified files to commit
|
# Check if there are any new or modified files to commit
|
||||||
if [ -n "$(get_new_posts)" ]; then
|
if [ -n "$new_posts" ]; then
|
||||||
# Add all new and modified files
|
# Add all new and modified files
|
||||||
echo "$commit_msg"
|
echo "$commit_msg"
|
||||||
git add $(get_new_posts)
|
git add $new_posts
|
||||||
|
for post in $new_posts; do
|
||||||
|
echo $post
|
||||||
|
post="${post#_posts/}"
|
||||||
|
git add "assets/img/${post%.md}"
|
||||||
|
done
|
||||||
|
|
||||||
# Commit the changes with the generated message
|
Commit the changes with the generated message
|
||||||
git commit -m "$commit_msg"
|
git commit -m "$commit_msg"
|
||||||
git push
|
git push
|
||||||
echo "Changes committed successfully."
|
echo "Changes committed successfully."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user