#!/usr/bin/env python3 """Fix product image references in markdown files""" import os import re PRODUCT_IMAGE_MAP = { 'hdpe.md': 'hdpe-page-full.png', 'poloplast.md': 'poloplast_000C.jpg', 'ppr-elephant.md': 'ppr-pipe_000C.jpg', 'syler.md': 'syler_000C.jpg', 'thai-ppr.md': 'ppr-pipe_000C.jpg', 'xylent.md': 'xylent_000C.jpg', } def fix_markdown_file(filepath, image_name): """Fix image reference in markdown file""" with open(filepath, 'r', encoding='utf-8') as f: content = f.read() # Replace image field content = re.sub( r'image:\s*/images/2021/03/[^\\s]+', f'image: /images/2021/03/{image_name}', content ) with open(filepath, 'w', encoding='utf-8') as f: f.write(content) print(f"✓ Fixed {os.path.basename(filepath)} -> {image_name}") def main(): products_dir = '/Users/kunthawatgreethong/Gitea/dealplustech/src/content/products' for filename, image_name in PRODUCT_IMAGE_MAP.items(): filepath = os.path.join(products_dir, filename) if os.path.exists(filepath): fix_markdown_file(filepath, image_name) else: print(f"✗ Not found: {filename}") if __name__ == '__main__': main()