import os
import re

html_files = [
    'index.html',
    'construction-company-in-krishnagiri.html',
    'home-builder-in-krishnagiri.html',
    'architecture-firm-in-krishnagiri.html',
    'interior-designers-in-krishnagiri.html',
    'about-us.html',
    'faq.html',
    'contact-us.html'
]

dir_path = r'd:\xampp\htdocs\mkconstruction'

for filename in html_files:
    filepath = os.path.join(dir_path, filename)
    with open(filepath, 'r', encoding='utf-8') as f:
        content = f.read()

    # Injecting the Home link right after the opening <ul>
    content = re.sub(
        r'(<ul\s+class="nav-links"\s+id="navLinks">\s*)(<li\s+class="dropdown">\s*<a\s+href="[^"]*"\s+class="has-dropdown">\s*Services)',
        r'\1<li><a href="index.html">Home</a></li>\n                \2',
        content
    )
    
    with open(filepath, 'w', encoding='utf-8') as f:
        f.write(content)

print("Home menu added to all pages.")
