diff --git a/scripts/package.ps1 b/scripts/package.ps1 index 9993c0a..8d20c8e 100644 --- a/scripts/package.ps1 +++ b/scripts/package.ps1 @@ -41,11 +41,20 @@ $texts = Get-ChildItem $root -Recurse -File -Filter *.json | ForEach-Object { # release is numbered. $version = (Get-Content $Manifest -Raw | ConvertFrom-Json).version_number +# Thunderstore renders the README on the mod page but does not resolve in-page anchors, so a +# link like [changelog](#v151) goes nowhere there. The package gets a copy with those links turned +# into plain text - the same thing nexus-readme.py does for Nexus. The README in the repo keeps +# them, because they work on the wiki and on the git host. +$readmeText = [System.IO.File]::ReadAllText((Resolve-Path $Readme).Path) +$readmeText = [regex]::Replace($readmeText, '\[([^\]]+)\]\(#[^)]*\)', '$1') +$packagedReadme = Join-Path ([System.IO.Path]::GetTempPath()) ("RacesOfValheim_README_" + [guid]::NewGuid().ToString('N') + ".md") +[System.IO.File]::WriteAllText($packagedReadme, $readmeText, (New-Object System.Text.UTF8Encoding($false))) + # Thunderstore gives every package a folder of its own, so the texts sit at the zip root. $thunderstore = @( [pscustomobject]@{ Source = $Dll; Name = 'RacesOfValheim.dll' } [pscustomobject]@{ Source = $Manifest; Name = 'manifest.json' } - [pscustomobject]@{ Source = $Readme; Name = 'README.md' } + [pscustomobject]@{ Source = $packagedReadme; Name = 'README.md' } [pscustomobject]@{ Source = $Icon; Name = 'icon.png' } ) + ($texts | ForEach-Object { [pscustomobject]@{ Source = $_.Source; Name = "Translations/$($_.Rel)" } }) @@ -56,3 +65,5 @@ $nexus = @( New-ModZip (Join-Path $OutDir "RacesOfValheim_Thunderstore_$version.zip") $thunderstore New-ModZip (Join-Path $OutDir "RacesOfValheim_Nexus_$version.zip") $nexus + +Remove-Item $packagedReadme -Force