#!/usr/bin/env bash
# Apakah artikel terjadwal (future) sudah ada di sitemap? Dan seperti apa isi post-sitemap sekarang?
set -u
UA="Mozilla/5.0"
TS=$(date +%s)
curl -s -4 --max-time 60 -A "$UA" "https://studiosoft.id/post-sitemap.xml?nc=$TS" -o /tmp/ss_sm.xml -w "sitemap http=%{http_code} size=%{size_download}\n"
echo -n "jumlah URL di post-sitemap: "; grep -c "<loc>" /tmp/ss_sm.xml
echo "--- artikel terjadwal (24-28 Sep) ada di sitemap?"
for slug in "ai-dan-pekerjaan-digital-marketer" "apa-itu-geo" "cara-bikin-prompt-ai" "bikin-konten-pakai-ai" "tools-ai-untuk-bisnis"; do
  n=$(grep -c "$slug" /tmp/ss_sm.xml || true)
  printf "  %-38s %s\n" "$slug" "$n"
done
echo "--- tanggal lastmod terbaru di sitemap:"
grep -o -E "<lastmod>[^<]+" /tmp/ss_sm.xml | sort -r | head -3
echo "--- cek status artikel terjadwal via API:"
curl -s -4 --max-time 60 -u 'bambangbot:q26r RePo BVy6 pwU2 F3z7 ouyl' "https://studiosoft.id/wp-json/wp/v2/posts?per_page=5&status=future&_fields=id,slug,status,date,date_gmt,link" | python3 -c "
import json,sys
for p in json.load(sys.stdin):
    print(f\"  #{p['id']} {p['status']} | {p['date']} | {p['link'][:70]}\")
"