-
Notifications
You must be signed in to change notification settings - Fork 11
/
build_site.py
35 lines (24 loc) · 949 Bytes
/
build_site.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import shutil
from pathlib import Path
from bft.html.builder import build_site
def copy_with_progress(src, dst, copy_function=shutil.copy2):
for source_path in Path(src).rglob('*'):
relative_path = source_path.relative_to(src)
destination_path = dst / relative_path
if source_path.is_file():
destination_path.parent.mkdir(parents=True, exist_ok=True)
copy_function(source_path, destination_path)
print(f"Copying: {source_path} -> {destination_path}")
root = Path(__file__).parent.resolve()
index = root / "index.yaml"
dest = root / "dist"
# Remove the destination directory if it exists
if dest.exists():
shutil.rmtree(dest)
# Create the destination directory
dest.mkdir()
build_site(index, dest)
static_content_dir = root / "static_site"
# Use the custom copy_with_progress function
copy_with_progress(static_content_dir, dest)
print("Copying static files completed.")