Output folder instead of .output + now build.py pass the build dir var to html_generator.py + new README with link to the wiki
This commit is contained in:
@ -23,9 +23,10 @@ def render_gallery_images(images):
|
||||
"""
|
||||
return html
|
||||
|
||||
def generate_gallery_json_from_images(images, output_path):
|
||||
def generate_gallery_json_from_images(images, output_dir):
|
||||
try:
|
||||
img_list = [img["src"] for img in images]
|
||||
output_path = output_dir / "data" / "gallery.json"
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
json.dump(img_list, f, indent=2)
|
||||
@ -33,7 +34,7 @@ def generate_gallery_json_from_images(images, output_path):
|
||||
except Exception as e:
|
||||
logging.error(f"[✗] Error generating gallery JSON: {e}")
|
||||
|
||||
def generate_robots_txt(canonical_url, allowed_paths):
|
||||
def generate_robots_txt(canonical_url, allowed_paths, output_dir):
|
||||
robots_lines = ["User-agent: *"]
|
||||
for path in allowed_paths:
|
||||
robots_lines.append(f"Allow: {path}")
|
||||
@ -41,12 +42,12 @@ def generate_robots_txt(canonical_url, allowed_paths):
|
||||
robots_lines.append("")
|
||||
robots_lines.append(f"Sitemap: {canonical_url}/sitemap.xml")
|
||||
content = "\n".join(robots_lines)
|
||||
output_path = Path(".output/robots.txt")
|
||||
output_path = output_dir / "robots.txt"
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
logging.info(f"[✓] robots.txt generated at {output_path}")
|
||||
|
||||
def generate_sitemap_xml(canonical_url, allowed_paths):
|
||||
def generate_sitemap_xml(canonical_url, allowed_paths, output_dir):
|
||||
urlset_start = '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
|
||||
urlset_end = '</urlset>\n'
|
||||
urls = ""
|
||||
@ -54,7 +55,7 @@ def generate_sitemap_xml(canonical_url, allowed_paths):
|
||||
loc = canonical_url.rstrip("/") + path
|
||||
urls += f" <url>\n <loc>{loc}</loc>\n </url>\n"
|
||||
sitemap_content = urlset_start + urls + urlset_end
|
||||
output_path = Path(".output/sitemap.xml")
|
||||
output_path = output_dir / "sitemap.xml"
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
f.write(sitemap_content)
|
||||
logging.info(f"[✓] sitemap.xml generated at {output_path}")
|
||||
|
Reference in New Issue
Block a user