huggingface/open-source-agent-contributions
12
1#!/bin/bash2set -e3 4echo "๐ Starting Hugging Face Space..."5 6# Ensure proper permissions for the app directory at runtime7chmod -R 755 /app/src/content/assets 2>/dev/null || true8 9# Check if Notion import is enabled and token is available10if [ "${ENABLE_NOTION_IMPORT:-false}" = "true" ] && [ -n "$NOTION_TOKEN" ] && [ -n "$NOTION_PAGE_ID" ]; then11 echo "๐ Notion import enabled - fetching content from Notion..."12 echo " Page ID: $NOTION_PAGE_ID"13 14 cd /app15 16 if npm run notion:import 2>&1; then17 echo "โ
Notion import completed successfully!"18 19 echo "๐จ Rebuilding site with Notion content..."20 npm run build 2>&121 22 # PDF export only if Playwright was installed at build time23 if [ "${ENABLE_PDF_EXPORT:-false}" = "true" ] && command -v chromium > /dev/null 2>&1; then24 echo "๐ Generating PDF..."25 npm run export:pdf -- --theme=light --wait=full 2>&1 || echo "โ ๏ธ PDF generation failed (non-critical)"26 else27 echo "โญ๏ธ Skipping PDF generation (Playwright not available)"28 fi29 30 echo "โ
Site rebuilt and ready!"31 else32 echo "โ ๏ธ Notion import failed - using pre-built content"33 fi34else35 if [ "${ENABLE_NOTION_IMPORT:-false}" = "true" ]; then36 echo "โ ๏ธ Notion import enabled but NOTION_TOKEN or NOTION_PAGE_ID not found"37 echo " NOTION_TOKEN: ${NOTION_TOKEN:+SET}${NOTION_TOKEN:-NOT SET}"38 echo " NOTION_PAGE_ID: ${NOTION_PAGE_ID:+SET}${NOTION_PAGE_ID:-NOT SET}"39 echo " โ Using pre-built content"40 else41 echo "โญ๏ธ Notion import disabled - serving pre-built content"42 fi43fi44 45echo "๐ Starting nginx on port 8080..."46exec nginx -g 'daemon off;'47 