all repos — py-vite @ 01a0f1b58711174f86c0a6b3ab8104556503c564

the original vite, written in python

Add date support

* {{ date }} in your template
* looks for the `date` frontmatter
Anirudh icyph0x@pm.me
Fri, 05 Apr 2019 18:45:41 +0530
commit

01a0f1b58711174f86c0a6b3ab8104556503c564

parent

a6835210312069ca7ddf5ec4c8cf8ababb4377f9

2 files changed, 8 insertions(+), 6 deletions(-)

jump to
M README.mdREADME.md

@@ -76,6 +76,8 @@

```markdown --- template: foo.html +title: Some fancy buzzwords here +date: 1 April, 2019 --- ## markdown here
M vite/vite.pyvite/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: