fix(package): the Thunderstore README has no in-page anchor links

Thunderstore renders the README on the mod page but does not resolve
anchors, so links like [changelog](#v151) went nowhere. The package now
gets a copy with those links turned into plain text, as nexus-readme.py
already does for Nexus. The repo README keeps them, since they work on
the wiki and the git host.
This commit is contained in:
kanym 2026-09-30 19:03:06 +02:00
commit 2ccb09e67a

View file

@ -41,11 +41,20 @@ $texts = Get-ChildItem $root -Recurse -File -Filter *.json | ForEach-Object {
# release is numbered. # release is numbered.
$version = (Get-Content $Manifest -Raw | ConvertFrom-Json).version_number $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 gives every package a folder of its own, so the texts sit at the zip root.
$thunderstore = @( $thunderstore = @(
[pscustomobject]@{ Source = $Dll; Name = 'RacesOfValheim.dll' } [pscustomobject]@{ Source = $Dll; Name = 'RacesOfValheim.dll' }
[pscustomobject]@{ Source = $Manifest; Name = 'manifest.json' } [pscustomobject]@{ Source = $Manifest; Name = 'manifest.json' }
[pscustomobject]@{ Source = $Readme; Name = 'README.md' } [pscustomobject]@{ Source = $packagedReadme; Name = 'README.md' }
[pscustomobject]@{ Source = $Icon; Name = 'icon.png' } [pscustomobject]@{ Source = $Icon; Name = 'icon.png' }
) + ($texts | ForEach-Object { [pscustomobject]@{ Source = $_.Source; Name = "Translations/$($_.Rel)" } }) ) + ($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_Thunderstore_$version.zip") $thunderstore
New-ModZip (Join-Path $OutDir "RacesOfValheim_Nexus_$version.zip") $nexus New-ModZip (Join-Path $OutDir "RacesOfValheim_Nexus_$version.zip") $nexus
Remove-Item $packagedReadme -Force