Update new_post.py

This commit is contained in:
Tom 2025-02-03 11:27:50 +00:00
parent cd80ff3ab8
commit df1cfdc384

View File

@ -63,12 +63,18 @@ image_class: invertable
---
"""
print(f"Will create new branch post/{id_from_title} based off main.")
print("Post header yaml will be:")
print(draft)
if not questionary.confirm("Create post?").ask():
sys.exit()
repo.git.checkout("main")
repo.git.checkout("-b", f"post/{id_from_title}")
with open(f"_posts/{filename}", "w") as f:
f.write(draft)
print(f"Made new post at _posts/{filename}")
if questionary.confirm(f"Create {assets_dir}").ask():
@ -78,4 +84,7 @@ Path("highlights.md").touch()
Path("blog.md").touch()
url = f"http://localhost:4100/{now.strftime('%Y/%m/%d/')}{id_from_title}.html"
system(f"open {url}")
system(f"open {url}")
print(f"Now on new branch post/{id_from_title}")
print("Make sure to edit, then commit and push changes.")