From 9d0a78bd95d3efdf6085581876b608d20d697eab Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Mon, 7 Aug 2017 15:27:16 +0300 Subject: Add intro blog post and logo in header --- app.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 97fe702..fc4ab4a 100644 --- a/app.py +++ b/app.py @@ -23,15 +23,15 @@ def blog(): posts = map(parse_post, posts) return render_template('blog.html', posts=posts) -@app.route('/blog/////') -def blog_post(y, m, d, title): - post_path = f'{y}-{m}-{d}-{title}' +@app.route('/blog/<y>/<m>/<d>/<slug>/') +def blog_post(y, m, d, slug): + post_path = f'{y}-{m}-{d}-{slug}' with open(f'{BLOG_CONTENT_DIR}/{post_path}.md', 'r') as f: text = f.read() _, header, body = text.split('---') - for h in header: + for h in header.split('\n'): if h.startswith('title'): - title = h.split('title:')[0].strip() + title = h.split('title:')[1].strip() html = markdown.markdown(body, extensions=['markdown.extensions.extra', 'markdown.extensions.codehilite']) return render_template('blog-post.html', title=title, html=html) -- cgit v1.3.1