mirror of
https://github.com/TomHodson/tomhodson.github.com.git
synced 2025-06-26 10:01:18 +02:00
Update new_post.py
This commit is contained in:
parent
c6107b786a
commit
69eaa092b7
@ -21,8 +21,20 @@ if repo.untracked_files or repo.is_dirty():
|
|||||||
|
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
|
||||||
|
title = questionary.text("Title: ").ask()
|
||||||
|
|
||||||
|
shorter_title = ""
|
||||||
|
for word in title.split():
|
||||||
|
if len(shorter_title) + len(word) < 100:
|
||||||
|
shorter_title += word + " "
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
shorter_title = shorter_title.strip()
|
||||||
|
|
||||||
|
id_from_title = shorter_title.lower().replace(" ", "-").replace(".", "").replace(",", "").replace(":", "")
|
||||||
|
id_from_title = questionary.text("id_from_title: ", default=id_from_title).ask()
|
||||||
|
|
||||||
answers = questionary.form(
|
answers = questionary.form(
|
||||||
title = questionary.text("Title: "),
|
|
||||||
excerpt = questionary.text("Excerpt: "),
|
excerpt = questionary.text("Excerpt: "),
|
||||||
date = questionary.text("Date: ", default=now.strftime("%Y-%m-%d")),
|
date = questionary.text("Date: ", default=now.strftime("%Y-%m-%d")),
|
||||||
libraries = questionary.checkbox(
|
libraries = questionary.checkbox(
|
||||||
@ -35,14 +47,7 @@ answers = questionary.form(
|
|||||||
),
|
),
|
||||||
).ask()
|
).ask()
|
||||||
|
|
||||||
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 = f"{answers['date']}-{id_from_title}.md"
|
||||||
filename = questionary.text("Filename: ", default=filename).ask()
|
filename = questionary.text("Filename: ", default=filename).ask()
|
||||||
|
|
||||||
@ -57,7 +62,7 @@ git_branch = questionary.text("Branch: ", default=f"post/{id_from_title}").ask()
|
|||||||
|
|
||||||
newline = "\n"
|
newline = "\n"
|
||||||
draft = f"""---
|
draft = f"""---
|
||||||
title: {answers['title']}
|
title: {title}
|
||||||
layout: post
|
layout: post
|
||||||
excerpt: {answers['excerpt']}
|
excerpt: {answers['excerpt']}
|
||||||
draft: true
|
draft: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user