From c6107b786aef52090e800e148d07f2031f989139 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 16 Feb 2025 17:35:17 +0000 Subject: [PATCH] Update new_post.py --- scripts/new_post.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/new_post.py b/scripts/new_post.py index f18c4bc..a785142 100755 --- a/scripts/new_post.py +++ b/scripts/new_post.py @@ -35,7 +35,14 @@ answers = questionary.form( ), ).ask() -id_from_title = answers['title'].lower().replace(" ", "-") +shorter_title = "" +for word in answers['title'].split(" "): + if len(shorter_title) + len(word) < 100: + shorter_title += word + " " + else: + break + +id_from_title = shorter_title.lower().replace(" ", "-") filename = f"{answers['date']}-{id_from_title}.md" filename = questionary.text("Filename: ", default=filename).ask() @@ -46,7 +53,7 @@ if Path(assets_dir).exists() \ and questionary.confirm(f"Directory {assets_dir} already exists, change assets dir?").ask(): assets_dir = questionary.text("Assets Directory: ", default=assets_dir).ask() -git_branch = questionary.text("Branch: ", default=f"post/{id_from_title[:100]}").ask() +git_branch = questionary.text("Branch: ", default=f"post/{id_from_title}").ask() newline = "\n" draft = f"""---