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
|
||||
from slugify import slugify
|
||||
iso_date = datetime.datetime.today().strftime('%Y-%m-%d')
|
||||
year, month, day = iso_date.split("-")
|
||||
title = input("Title: ")
|
||||
slug = slugify(title)
|
||||
filename = f"{iso_date}_{slug}.rst"
|
||||
title_header = "#" * len(title)
|
||||
template = f"""{title}
|
||||
{title_header}
|
||||
:date: {datetime.datetime.today().strftime('%Y-%m-%d %H:%M')}
|
||||
:author: tyrel
|
||||
:category: ????
|
||||
:tags: ????
|
||||
:slug: {slug}
|
||||
:status: draft
|
||||
|
||||
"""
|
||||
base = f"content/blog/{year}/{month}"
|
||||
base = f"content/blog"
|
||||
os.makedirs(os.path.dirname(base), exist_ok=True)
|
||||
with open(f"{base}/{filename}", "w") as f:
|
||||
f.write(template)
|
||||
|
Loading…
Reference in New Issue
Block a user