img rework and slag in new website
This commit is contained in:
parent
9d522c6b54
commit
c87a34229b
|
@ -18,7 +18,7 @@ def migrate_header_img_and_return_new_path_for_post(img_path, img_new_path):
|
||||||
old = g_input + str(output_path.parent.name) + '/' + str(output_path.name) + '/' + img_path
|
old = g_input + str(output_path.parent.name) + '/' + str(output_path.name) + '/' + img_path
|
||||||
new = img_new_path + '/' + img_pathlib.name
|
new = img_new_path + '/' + img_pathlib.name
|
||||||
shutil.copyfile(old, new)
|
shutil.copyfile(old, new)
|
||||||
return new.replace(new.split('/')[0], '/blog')
|
return str(img_pathlib.name)
|
||||||
|
|
||||||
|
|
||||||
def convert_m2h(input_file: str, output_dir: str):
|
def convert_m2h(input_file: str, output_dir: str):
|
||||||
|
@ -65,15 +65,18 @@ def convert_m2h(input_file: str, output_dir: str):
|
||||||
|
|
||||||
if 'header_image' in data:
|
if 'header_image' in data:
|
||||||
new_img_path = migrate_header_img_and_return_new_path_for_post(data['header_image'], output_dir)
|
new_img_path = migrate_header_img_and_return_new_path_for_post(data['header_image'], output_dir)
|
||||||
|
if new_img_path is not None:
|
||||||
header = {'image': new_img_path, 'caption': 'Sorry this blog entry was migrated, there is no Alt-Text'}
|
header = {'image': new_img_path, 'caption': 'Sorry this blog entry was migrated, there is no Alt-Text'}
|
||||||
del data['header_image']
|
|
||||||
data['header'] = header
|
data['header'] = header
|
||||||
|
del data['header_image']
|
||||||
|
|
||||||
if 'author' in data:
|
if 'author' in data:
|
||||||
data['authors'] = data['author']['display_name'].split(', ')
|
data['authors'] = data['author']['display_name'].split(', ')
|
||||||
# delete fields
|
# delete fields
|
||||||
del data['author']
|
del data['author']
|
||||||
|
|
||||||
|
data['slug'] = re.sub(r'\d{4}-\d{2}-\d{2}-', '', output_dir.split('/').pop()) + '-index'
|
||||||
|
|
||||||
if 'meta' in data:
|
if 'meta' in data:
|
||||||
del data['meta']
|
del data['meta']
|
||||||
if 'published' in data:
|
if 'published' in data:
|
||||||
|
|
Loading…
Reference in a new issue