diff options
| author | Yuval Adam <_@yuv.al> | 2017-08-07 15:27:16 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2017-08-07 15:27:16 +0300 |
| commit | 9d0a78bd95d3efdf6085581876b608d20d697eab (patch) | |
| tree | dc57cfbb15d781205e17aa73df157b00c5dbc86d /app.py | |
| parent | bfed87461985a50898d0a00147d0147b59265a23 (diff) | |
Add intro blog post and logo in header
Diffstat (limited to 'app.py')
| -rw-r--r-- | app.py | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -23,15 +23,15 @@ def blog(): posts = map(parse_post, posts) return render_template('blog.html', posts=posts) -@app.route('/blog/<y>/<m>/<d>/<title>/') -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) |
