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