Add date support * {{ date }} in your template * looks for the `date` frontmatter
Anirudh icyph0x@pm.me
Fri, 05 Apr 2019 18:45:41 +0530
2 files changed,
8 insertions(+),
6 deletions(-)
M
vite/vite.py
→
vite/vite.py
@@ -56,7 +56,7 @@
def create_path(path): head, tail = os.path.split(path) now = datetime.datetime.now() - today = now.strftime('%Y-%m-%d') + today = now.strftime('%d %B, %Y') try: os.makedirs(os.path.join(PAGES_PATH, head))@@ -67,10 +67,10 @@ print(bad('Error: specified path exists.'))
else: with open(os.path.join(PAGES_PATH, head, tail), 'w') as f: f.write(f"""--- - template: - title: - date: {today} - ---\n""") +template: +title: +date: {today} +---\n""") print(good('Created %s.') % (os.path.join(PAGES_PATH, head, tail)))@@ -114,11 +114,11 @@ env = jinja2.Environment(loader=template_loader)
try: template = env.get_template(tmpl) meta = html.metadata - print(meta) output = template.render(title=meta['title'] if 'title' in meta else config.title, author=meta['author'] if 'author' in meta else config.author, header=meta['header'] if 'header' in meta else config.header, footer=meta['footer'] if 'footer' in meta else config.footer, + date=meta['date'] if 'date' in meta else '', body=html) return output except jinja2.exceptions.TemplateNotFound: