From c87a34229b7bce7c600b2bb78e32aa2843252de2 Mon Sep 17 00:00:00 2001 From: c6ristian Date: Thu, 30 Nov 2023 22:57:52 +0100 Subject: [PATCH] img rework and slag in new website --- convert2.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/convert2.py b/convert2.py index 7d1df1f..b0591e8 100644 --- a/convert2.py +++ b/convert2.py @@ -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: