Merge pull request #415 from muhammad-ali-imply/marketing/home-page-edits

diff --git a/scripts/build_docs.py b/scripts/build_docs.py
index a47fb3d..0400574 100644
--- a/scripts/build_docs.py
+++ b/scripts/build_docs.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+
 """
 build-docs.py
 
@@ -39,14 +40,13 @@
         replacement = f'var buildVersion = "{v}";'
         for line in fileinput.input("docusaurus.config.js", inplace=1):
             print(re.sub(r"^var buildVersion.*", replacement, line), end='')
-
+        shutil.rmtree(f"published_versions/docs/{v}", ignore_errors=True) 
         # build the docs
         if not use_yarn:
             subprocess.run(["npm", "run", "build"])
         else:
             subprocess.run(["yarn", "build"])
 
-
         # move output to temporary directory since docusaurus 2
         # overwrites build directory with each build.
         # the "latest" version is built last to maintain
@@ -87,7 +87,6 @@
 
     # remove the old build directory
     shutil.rmtree('build', ignore_errors=True)
-
     # do the actual builds
     build_docs(versions, use_yarn)
 
diff --git a/scripts/copy_druid_docs.py b/scripts/copy_druid_docs.py
index 8ca75f1..0ba304f 100755
--- a/scripts/copy_druid_docs.py
+++ b/scripts/copy_druid_docs.py
@@ -1,4 +1,3 @@
-from distutils.dir_util import copy_tree
 import os
 import shutil
 import subprocess
@@ -74,11 +73,7 @@
         item_path = os.path.join(file_path, item)
 
         # If the item is a file and has a markdown extension
-        if os.path.isfile(item_path) and item_path.lower().endswith(".md"):
-            replace_text_in_file(item_path, druid_version)
-
-        # If the item is a file and has a markdownx extension
-        if os.path.isfile(item_path) and item_path.lower().endswith(".mdx"):
+        if os.path.isfile(item_path) and (item_path.lower().endswith(".md") or item_path.lower().endswith(".mdx")):
             replace_text_in_file(item_path, druid_version)
 
         # If the item is a directory, recursively process its contents
@@ -90,7 +85,7 @@
 
     if is_latest == 'y':
         print("Also copying the docs to docs/latest.")
-        copy_tree(source_directory+'/docs', destination_directory_latest)
+        subprocess.run(["rsync", "--delete", "--recursive", f"{source_directory}/docs/", destination_directory_latest])
         shutil.rmtree(f"{destination_directory_latest}/_bin")
         do_the_replace(destination_directory_latest, druid_version)
     elif is_latest == 'n':
@@ -98,7 +93,6 @@
     else:
         print("Enter y or n to make a choice")
 
-
 def main(druid_version, source_directory="../../druid"):
     is_valid, error_msg = check_source(source_directory)
     if not is_valid:
@@ -109,7 +103,7 @@
     destination_directory_latest = "../docs/latest"
 
     # Copies the docs
-    copy_tree(source_directory+"/docs", destination_directory)
+    subprocess.run(["rsync", "--delete", "--recursive", f"{source_directory}/docs/", destination_directory])
 
     # deletes the _bin directory that's not needed
     shutil.rmtree(f"{destination_directory}/_bin")