#!/bin/bash # Uppdatera /insights/index.html med alla publicerade artiklar S3_BUCKET="s3://landvex-prod" CF_DIST_ID="E2M3J95HLUR89H" # Hämta lista över alla artiklar från S3 echo "Hämtar artiklar från S3..." aws s3 ls $S3_BUCKET/insights/ | grep "PRE" | awk '{print $2}' | sed 's|/||' > /tmp/article-slugs.txt # Generera HTML för varje artikel echo "Genererar insights-index..." ARTICLES_HTML="" while read slug; do if [ "$slug" != "" ] && [ "$slug" != "index.html" ]; then # Hämta titel från artikeln TITLE=$(curl -s "https://landvex.com/insights/$slug/" | grep -o '.*' | sed 's///;s/<\/title>//;s/ | Landvex//' | head -1) if [ -z "$TITLE" ]; then TITLE="$slug" fi ARTICLES_HTML="$ARTICLES_HTML <div class=\"article-card\"> <h2><a href=\"/insights/$slug/\">$TITLE</a></h2> </div>" fi done < /tmp/article-slugs.txt # Skapa komplett HTML cat > /tmp/insights-index.html << HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Intelligence Insights | Landvex Blog

Intelligence Insights

Research and analysis on decision intelligence, field data quality and the gap between official data and observed reality.

$ARTICLES_HTML
HTML # Upload aws s3 cp /tmp/insights-index.html $S3_BUCKET/insights/index.html --content-type "text/html" --cache-control "max-age=3600" # Invalidate aws cloudfront create-invalidation --distribution-id "$CF_DIST_ID" --paths "/insights/" --query 'Invalidation.Id' --output text echo "✅ Insights index uppdaterad"