added title to posts

This commit is contained in:
Solomon Laing 2021-06-06 12:43:36 +09:30
parent fa0d8a2ed7
commit 6cfdded7bb
3 changed files with 9 additions and 3 deletions

12
app.py
View File

@ -23,10 +23,12 @@ class Post(Resource):
_date = tokens[0]
_category = tokens[1]
_slug = tokens[2].replace('.md', '')
_title = tokens[2].replace('.md', '')
_slug = _title.lower().replace(' ', '-')
_post = {
"slug": _slug,
"title": _title,
"date": _date,
"category": _category,
"content": render(open(path+'/'+_file, 'r').read())
@ -38,11 +40,13 @@ class Post(Resource):
_date = tokens[0]
_category = tokens[1]
_slug = tokens[2].replace('.md', '')
_title = tokens[2].replace('.md', '')
_slug = _title.lower().replace(' ', '-')
if(_slug == slug):
_post = {
"slug": _slug,
"title": _title,
"date": _date,
"category": _category,
"content": render(open(path+'/'+_file, 'r').read())
@ -68,10 +72,12 @@ class Posts(Resource):
_date = tokens[0]
_category = tokens[1]
_slug = tokens[2].replace('.md', '')
_title = tokens[2].replace('.md', '')
_slug = _title.lower().replace(' ', '-')
_post = {
"slug": _slug,
"title": _title,
"date": _date,
"category": _category,
"content": render(open(path+'/'+_file, 'r').read())