all repos — py-vite @ 6c4c22b69615c0d489d80e346c345d682d562e18

the original vite, written in python

feat: now supports index.html! (homepage)
Anirudh icyph0x@pm.me
Tue, 12 Jun 2018 11:00:52 +0530
commit

6c4c22b69615c0d489d80e346c345d682d562e18

parent

0e0ae3850b920d43835a1a5fe3f494b7f6d80165

1 files changed, 17 insertions(+), 9 deletions(-)

jump to
M vite/vite.pyvite/vite.py

@@ -108,14 +108,22 @@

def html_gen(): for page in os.listdir(PAGES_PATH): - html_text = markdown_render(page) - html_file= os.path.splitext(os.path.join(BUILD_PATH, page))[0] - if not os.path.exists(html_file): - os.mkdir(html_file) - output = jinja_render(html_text, TEMPL_FILE) - with open(os.path.join(html_file, 'index.html'), 'w') as f: - f.write(output) - print(run('Rendered %s.' % (page))) + print(page) + if page == '_index.md': + index_html = markdown_render(page) + output = jinja_render(index_html, TEMPL_FILE) + with open(os.path.join(BUILD_PATH, 'index.html'), 'w') as f: + f.write(output) + print(run('Rendered index.html')) + else: + html_text = markdown_render(page) + html_file = os.path.splitext(os.path.join(BUILD_PATH, page))[0] + if not os.path.exists(html_file): + os.mkdir(html_file) + output = jinja_render(html_text, TEMPL_FILE) + with open(os.path.join(html_file, 'index.html'), 'w') as f: + f.write(output) + print(run('Rendered %s.' % (page))) def server():

@@ -146,4 +154,4 @@ copy_tree('static', os.path.join(path, BUILD_PATH, 'static'))

print(good('Done in %0.5fs.' % (time.process_time() - start))) except jinja2.exceptions.TemplateNotFound: print(bad('Error: specified template not found: %s' % TEMPL_FILE)) - +