File size: 1,742 Bytes
6afedde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e

echo "๐Ÿš€ Starting Hugging Face Space..."

# Ensure proper permissions for the app directory at runtime
echo "๐Ÿ”ง Setting up permissions..."
chmod -R 755 /app/src/content/assets 2>/dev/null || echo "โš ๏ธ  Could not set permissions (non-critical)"

# Check if Notion import is enabled and token is available
if [ "${ENABLE_NOTION_IMPORT:-false}" = "true" ] && [ -n "$NOTION_TOKEN" ] && [ -n "$NOTION_PAGE_ID" ]; then
    echo "๐Ÿ”„ Notion import enabled - fetching content from Notion..."
    echo "   Page ID: $NOTION_PAGE_ID"
    
    cd /app
    
    # Run notion import
    if npm run notion:import 2>&1; then
        echo "โœ… Notion import completed successfully!"
        
        # Rebuild the site with new content
        echo "๐Ÿ”จ Rebuilding site with Notion content..."
        npm run build 2>&1
        
        # Generate PDF
        echo "๐Ÿ“„ Generating PDF..."
        npm run export:pdf -- --theme=light --wait=full 2>&1 || echo "โš ๏ธ  PDF generation failed (non-critical)"
        
        echo "โœ… Site rebuilt and ready!"
    else
        echo "โš ๏ธ  Notion import failed - using pre-built content from build time"
    fi
else
    if [ "${ENABLE_NOTION_IMPORT:-false}" = "true" ]; then
        echo "โš ๏ธ  Notion import enabled but NOTION_TOKEN or NOTION_PAGE_ID not found"
        echo "   NOTION_TOKEN: ${NOTION_TOKEN:+SET}${NOTION_TOKEN:-NOT SET}"
        echo "   NOTION_PAGE_ID: ${NOTION_PAGE_ID:+SET}${NOTION_PAGE_ID:-NOT SET}"
        echo "   โ†’ Using pre-built content from build time"
    else
        echo "โญ๏ธ  Notion import disabled - using pre-built content from build time"
    fi
fi

# Start nginx
echo "๐ŸŒ Starting nginx on port 8080..."
exec nginx -g 'daemon off;'