Fix verse sitemap generation - suppress WeasyPrint warnings

The sitemap-verses.xml file was contaminated with WeasyPrint import
warnings, causing "Document is empty" errors in Google Search Console.

Fixes:
- Suppress stdout/stderr during imports to prevent warnings in output
- Add error handling to sitemap-verses endpoint
- Regenerate clean sitemap-verses.xml (6.3MB, 31,102 verses)

The file now starts with proper XML declaration instead of error messages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-27 19:37:34 -05:00
parent f9ce3861ff
commit 3493c43144
3 changed files with 25 additions and 10 deletions
+13
View File
@@ -26,13 +26,26 @@ Usage:
git commit -m "Update verse sitemap"
"""
import sys
import os
from pathlib import Path
# Suppress WeasyPrint warnings during import
# Redirect stdout temporarily to suppress import warnings
from io import StringIO
old_stdout = sys.stdout
old_stderr = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
# Add parent directory to path to import kjv module
sys.path.insert(0, str(Path(__file__).parent.parent))
from kjvstudy_org.kjv import bible
# Restore stdout/stderr
sys.stdout = old_stdout
sys.stderr = old_stderr
def generate_verse_sitemap():
"""Generate sitemap XML for all verses in the Bible."""