tasks
This commit is contained in:
parent
519ecb1366
commit
24088965ed
5
tasks.py
5
tasks.py
@ -148,22 +148,19 @@ def new_post(c):
|
|||||||
import os
|
import os
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
iso_date = datetime.datetime.today().strftime('%Y-%m-%d')
|
iso_date = datetime.datetime.today().strftime('%Y-%m-%d')
|
||||||
year, month, day = iso_date.split("-")
|
|
||||||
title = input("Title: ")
|
title = input("Title: ")
|
||||||
slug = slugify(title)
|
slug = slugify(title)
|
||||||
filename = f"{iso_date}_{slug}.rst"
|
filename = f"{iso_date}_{slug}.rst"
|
||||||
title_header = "#" * len(title)
|
title_header = "#" * len(title)
|
||||||
template = f"""{title}
|
template = f"""{title}
|
||||||
{title_header}
|
{title_header}
|
||||||
:date: {datetime.datetime.today().strftime('%Y-%m-%d %H:%M')}
|
|
||||||
:author: tyrel
|
:author: tyrel
|
||||||
:category: ????
|
:category: ????
|
||||||
:tags: ????
|
:tags: ????
|
||||||
:slug: {slug}
|
|
||||||
:status: draft
|
:status: draft
|
||||||
|
|
||||||
"""
|
"""
|
||||||
base = f"content/blog/{year}/{month}"
|
base = f"content/blog"
|
||||||
os.makedirs(os.path.dirname(base), exist_ok=True)
|
os.makedirs(os.path.dirname(base), exist_ok=True)
|
||||||
with open(f"{base}/{filename}", "w") as f:
|
with open(f"{base}/{filename}", "w") as f:
|
||||||
f.write(template)
|
f.write(template)
|
||||||
|
Loading…
Reference in New Issue
Block a user