Update new_post.py

This commit is contained in:
Tom 2025-02-03 11:29:05 +00:00
parent df1cfdc384
commit 2d5be13d47

View File

@ -46,6 +46,7 @@ if Path(assets_dir).exists() \
and questionary.confirm(f"Directory {assets_dir} already exists, change assets dir?").ask(): and questionary.confirm(f"Directory {assets_dir} already exists, change assets dir?").ask():
assets_dir = questionary.text("Assets Directory: ", default=assets_dir).ask() assets_dir = questionary.text("Assets Directory: ", default=assets_dir).ask()
git_branch = questionary.text("Branch: ", default=f"post/{id_from_title}").ask()
draft = f"""--- draft = f"""---
title: {answers['title']} title: {answers['title']}
@ -70,7 +71,7 @@ if not questionary.confirm("Create post?").ask():
sys.exit() sys.exit()
repo.git.checkout("main") repo.git.checkout("main")
repo.git.checkout("-b", f"post/{id_from_title}") repo.git.checkout("-b", git_branch)
with open(f"_posts/{filename}", "w") as f: with open(f"_posts/{filename}", "w") as f:
f.write(draft) f.write(draft)