Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
89 lines
3.4 KiB
PowerShell
89 lines
3.4 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Push local markdown files from /pages/ folder as Confluence pages
|
|
.DESCRIPTION
|
|
Reads all .md files from the /pages/ directory, converts them to HTML,
|
|
and creates/updates them as child pages under the configured root page.
|
|
.USAGE
|
|
powershell -ExecutionPolicy Bypass -File scripts/confluence-push.ps1
|
|
#>
|
|
|
|
. "$PSScriptRoot/../config.ps1"
|
|
. "$PSScriptRoot/lib/confluence-api.ps1"
|
|
|
|
Write-Host "============================================================"
|
|
Write-Host " Confluence Push - $SpaceKey"
|
|
Write-Host "============================================================"
|
|
Write-Host " Target: $ConfluenceUrl/spaces/$SpaceKey"
|
|
Write-Host " Parent: $RootPageId"
|
|
Write-Host ""
|
|
|
|
# Test connection
|
|
Write-Host ">> Testing connection..." -ForegroundColor Yellow
|
|
$Test = Invoke-ConfluenceApi -Endpoint "/content/$RootPageId"
|
|
if (-not $Test) { Write-Host " Connection failed!" -ForegroundColor Red; exit 1 }
|
|
Write-Host " Target page: $($Test.title)" -ForegroundColor Green
|
|
|
|
# Find markdown files to push
|
|
$PagesPath = Join-Path $ProjectDir "pages"
|
|
if (-not (Test-Path $PagesPath)) {
|
|
Write-Host " No /pages/ directory found. Create it and add .md files." -ForegroundColor Yellow
|
|
exit 0
|
|
}
|
|
|
|
$MdFiles = Get-ChildItem -Path $PagesPath -Filter "*.md" | Sort-Object Name
|
|
if ($MdFiles.Count -eq 0) {
|
|
Write-Host " No .md files found in /pages/" -ForegroundColor Yellow
|
|
exit 0
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host ">> Pushing $($MdFiles.Count) pages..." -ForegroundColor Yellow
|
|
|
|
function Convert-MdToHtml($mdContent) {
|
|
# Simple markdown to Confluence storage format conversion
|
|
$html = $mdContent
|
|
# Headers
|
|
$html = $html -replace '^#### (.+)$', '<h4>$1</h4>'
|
|
$html = $html -replace '^### (.+)$', '<h3>$1</h3>'
|
|
$html = $html -replace '^## (.+)$', '<h2>$1</h2>'
|
|
$html = $html -replace '^# (.+)$', '<h1>$1</h1>'
|
|
# Bold/italic
|
|
$html = $html -replace '\*\*(.+?)\*\*', '<strong>$1</strong>'
|
|
$html = $html -replace '\*(.+?)\*', '<em>$1</em>'
|
|
# Lists
|
|
$html = $html -replace '^- (.+)$', '<li>$1</li>'
|
|
# Code blocks
|
|
$html = $html -replace '```(\w*)\n([\s\S]*?)```', '<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">$1</ac:parameter><ac:plain-text-body><![CDATA[$2]]></ac:plain-text-body></ac:structured-macro>'
|
|
# Inline code
|
|
$html = $html -replace '`(.+?)`', '<code>$1</code>'
|
|
# Paragraphs (lines not already tagged)
|
|
$lines = $html -split "`n"
|
|
$result = @()
|
|
foreach ($line in $lines) {
|
|
if ($line -match '^<' -or $line.Trim() -eq '') {
|
|
$result += $line
|
|
} else {
|
|
$result += "<p>$line</p>"
|
|
}
|
|
}
|
|
return $result -join "`n"
|
|
}
|
|
|
|
foreach ($File in $MdFiles) {
|
|
$Content = Get-Content $File.FullName -Raw -Encoding UTF8
|
|
# Use filename (without .md) as page title, or first # heading
|
|
$Title = $File.BaseName
|
|
if ($Content -match '^# (.+)$') { $Title = $Matches[1] }
|
|
|
|
Write-Host " $Title..." -NoNewline
|
|
$HtmlBody = Convert-MdToHtml $Content
|
|
$PageId = Create-Or-Update-Page -Title $Title -HtmlBody $HtmlBody -ParentId $RootPageId
|
|
if ($PageId) { Write-Host "" }
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "============================================================" -ForegroundColor Green
|
|
Write-Host " Done! $($MdFiles.Count) pages processed." -ForegroundColor Green
|
|
Write-Host "============================================================" -ForegroundColor Green
|