OldDocsFix.ps1 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # This script was used to fix the links in the old Stride documentation after the main Stride Website update so there are no dependencies
  2. # specify your directory path
  3. $path = 'd:\Projects\GitHub\stride-docs-live-fix-2\'
  4. $replacements = @{
  5. '//stride3d.net/css/site.css' = 'css/site.css';
  6. '//xenko.com/css/site.css' = 'css/site.css';
  7. '//stride3d.net/scripts/site.doc.js' = 'scripts/site.doc.js';
  8. '//xenko.com/scripts/site.doc.js' = 'scripts/site.doc.js';
  9. '//stride3d.net/favicon.png' = 'favicon.png';
  10. '//xenko.com/favicon.png' = 'favicon.png';
  11. '//stride3d.net/scripts/theme.js' = 'scripts/theme.js';
  12. '//xenko.com/scripts/theme.js' = 'scripts/theme.js';
  13. }
  14. $files = Get-ChildItem -Path $path -Filter *.html -Recurse
  15. $fileCount = $files.Count
  16. $i = 0
  17. foreach ($file in $files) {
  18. # if ($i -ge 100) { break } # Exit loop after 100 items
  19. $i++
  20. $content = Get-Content $file.FullName -Encoding UTF8 -Raw
  21. # Get content of 'docfx:rel' meta tag
  22. $metaContent = ""
  23. if ($content -match '<meta\s+property="docfx:rel"\s+content="([^"]*)">') {
  24. if ($Matches.Count -gt 1) {
  25. $metaContent = $Matches[1]
  26. }
  27. }
  28. $replacements.Keys | ForEach-Object {
  29. $content = $content -replace $_, ($metaContent + $replacements[$_])
  30. }
  31. Set-Content -Path $file.FullName -Value $content -Encoding UTF8
  32. # Update progress bar
  33. Write-Progress -Activity "Processing Files" -Status "$i of $fileCount processed" -PercentComplete (($i / $fileCount) * 100)
  34. }
  35. Write-Progress -Activity "Processing Files" -Completed