feat: vite now loads info from config.py
icyphox icyph0x@protonmail.com
Sat, 17 Mar 2018 16:22:04 +0530
M
make.py
→
make.py
@@ -1,7 +1,15 @@
from markdown2 import markdown_path from glob import glob import os +import sys import jinja2 + +# import config file +try: + sys.path.append(os.getcwd()) + import config +except ImportError: + print('Error: config.py not found') # constants PAGES_PATH = 'pages/'@@ -13,7 +21,7 @@ def jinja_render(html_text, template_file):
template_loader = jinja2.FileSystemLoader('./') env = jinja2.Environment(loader=template_loader) template = env.get_template(template_file) - output = template.render(title='test', body=html_text) + output = template.render(title=config.title, author=config.author, header=config.header, footer=config.footer, body=html_text) return output def markdown_render(filename):
M
vite.py
→
vite.py
@@ -30,8 +30,8 @@ pathlib.Path(path + '/templates').mkdir(exist_ok=False)
create_config(path) os.symlink(cur_path / 'make.py', abs_path / 'make.py') print('Created project directory at %s.' % (abs_path)) - except FileExistsError as e: - print('Error: specified path exists.') + except FileExistsError: + print('Error: specified path exists') def create_config(path): with open(path + '/config.py', 'w') as f: