|
@@ -18,11 +18,20 @@ def _get_data(file_dir):
|
|
|
data_field.remove('title:')
|
|
|
s = line.split('"')
|
|
|
result['title'] = s[1]
|
|
|
+ elif 'date:' in line:
|
|
|
+ #data_field.remove('date: ')
|
|
|
+ s = line.replace('date: ', '').strip()
|
|
|
+ result['date'] = s
|
|
|
+ elif 'draft:' in line:
|
|
|
+ #data_field.remove('draft: ')
|
|
|
+ s = line.replace('draft: ', '').strip()
|
|
|
+ result['draft'] = s
|
|
|
elif 'url:' in line:
|
|
|
data_field.remove('url:')
|
|
|
s = line.split('"')
|
|
|
result['url'] = s[1]
|
|
|
|
|
|
+
|
|
|
data_field = list(DATA_FIELD)
|
|
|
result = {}
|
|
|
with open(file_dir, 'r', encoding="utf-8") as md:
|
|
@@ -179,9 +188,11 @@ def gen_content():
|
|
|
dir_ = path.join(_search_content_dir(
|
|
|
request.json.get('type'), request.json.get('categories')), name)
|
|
|
if dir_:
|
|
|
- mkdir(dir_)
|
|
|
- mkdir(path.join(dir_, 'img'))
|
|
|
- with open(path.join(dir_, 'index.md'), 'w') as md:
|
|
|
+ if not path.exists(dir_):
|
|
|
+ mkdir(dir_)
|
|
|
+ if not path.exists(path.join(dir_, 'img')):
|
|
|
+ mkdir(path.join(dir_, 'img'))
|
|
|
+ with open(path.join(dir_, 'index.md'), 'w', encoding="utf-8") as md:
|
|
|
md.write(front_matter)
|
|
|
return {'new_content': name}
|
|
|
|