Write-Host"[INFO] Starting Algolia index upload..."-ForegroundColor Green
# Set Admin API Key (must match apiKey in _config.yml) $env:HEXO_ALGOLIA_INDEXING_KEY="xxxxxxxxxxxxxxxxxxxxxxxxx"
# Upload index Write-Host"[INFO] Uploading articles to Algolia..."-ForegroundColor Yellow hexo algolia
if ($LASTEXITCODE-eq0) { Write-Host"" Write-Host"[SUCCESS] Upload completed!"-ForegroundColor Green Write-Host"" Write-Host"Next steps:"-ForegroundColor Cyan Write-Host" 1. Run: hexo cl"-ForegroundColor White Write-Host" 2. Run: hexo g"-ForegroundColor White Write-Host" 3. Run: hexo s"-ForegroundColor White Write-Host" 4. Test search function on your website"-ForegroundColor White } else { Write-Host"" Write-Host"[ERROR] Upload failed!"-ForegroundColor Red Write-Host"" Write-Host"Please check:"-ForegroundColor Yellow Write-Host" 1. Application ID is correct"-ForegroundColor White Write-Host" 2. Admin API Key is correct (must have write permission)"-ForegroundColor White Write-Host" 3. Index 'hexo' exists in Algolia dashboard"-ForegroundColor White Write-Host" 4. API Key has 'addObject', 'deleteObject', 'editSettings' permissions"-ForegroundColor White }
Write-Host"" Write-Host"[SUCCESS] Upload completed!"-ForegroundColor Green Write-Host"" Write-Host"Next steps:"-ForegroundColor Cyan Write-Host" 1. Run: hexo cl"-ForegroundColor White Write-Host" 2. Run: hexo g"-ForegroundColor White Write-Host" 3. Run: hexo s"-ForegroundColor White Write-Host" 4. Test search function on your website"-ForegroundColor White
设计理念:
✅ 明确告知用户操作成功
📋 提供后续操作步骤
🎨 使用不同颜色增强可读性
7. 失败提示(第 22-31 行)
1 2 3 4 5 6 7 8
Write-Host"" Write-Host"[ERROR] Upload failed!"-ForegroundColor Red Write-Host"" Write-Host"Please check:"-ForegroundColor Yellow Write-Host" 1. Application ID is correct"-ForegroundColor White Write-Host" 2. Admin API Key is correct (must have write permission)"-ForegroundColor White Write-Host" 3. Index 'hexo' exists in Algolia dashboard"-ForegroundColor White Write-Host" 4. API Key has 'addObject', 'deleteObject', 'editSettings' permissions"-ForegroundColor White
[INFO] Starting Algolia index upload... [INFO] Uploading articles to Algolia... INFO [hexo-algolia] Testing HEXO_ALGOLIA_INDEXING_KEY permissions. INFO Start processing INFO [hexo-algolia] 34 records to index (post, page). INFO [hexo-algolia] Indexing chunk 1 of 1 (34 records) INFO [hexo-algolia] Indexing done.
[SUCCESS] Upload completed!
Next steps: 1. Run: hexo cl 2. Run: hexo g 3. Run: hexo s 4. Test search function on your website
失败输出示例:
1 2 3 4 5 6 7 8 9 10 11
[INFO] Starting Algolia index upload... [INFO] Uploading articles to Algolia... ERROR [hexo-algolia] Not enough rights to update an object
[ERROR] Upload failed!
Please check: 1. Application ID is correct 2. Admin API Key is correct (must have write permission) 3. Index 'hexo' exists in Algolia dashboard 4. API Key has 'addObject', 'deleteObject', 'editSettings' permissions