@@ -128,6 +128,24 @@ function Update-MDSection {
128128 }
129129}
130130
131+ function Get-TemplateContent {
132+ <#
133+ . SYNOPSIS
134+ Reads a template file as raw text.
135+
136+ . DESCRIPTION
137+ Loads a UTF-8 template file from disk and returns the complete content as a string.
138+ #>
139+ [OutputType ([string ])]
140+ [CmdletBinding ()]
141+ param (
142+ [Parameter (Mandatory )]
143+ [string ] $Path
144+ )
145+
146+ Get-Content - Path $Path - Raw
147+ }
148+
131149function Get-PropertyValue {
132150 <#
133151 . SYNOPSIS
@@ -640,6 +658,13 @@ function Update-ModuleList {
640658 $Repos = Show-RepoList
641659 }
642660
661+ $moduleCatalogTemplateVersion = ' v2'
662+ $moduleCatalogTemplateFolder = Join-Path (Join-Path $PSScriptRoot ' ..' ) ' templates\module-catalog'
663+ $moduleCatalogRowTemplatePath = Join-Path $moduleCatalogTemplateFolder " $moduleCatalogTemplateVersion -row.html"
664+ $moduleCatalogTableTemplatePath = Join-Path $moduleCatalogTemplateFolder " $moduleCatalogTemplateVersion -table.html"
665+ $moduleCatalogRowTemplate = Get-TemplateContent - Path $moduleCatalogRowTemplatePath
666+ $moduleCatalogTableTemplate = Get-TemplateContent - Path $moduleCatalogTableTemplatePath
667+
643668 $moduleRepos = $Repos | Where-Object {
644669 $_.Type -eq ' Module' -and $_.Owner -eq ' PSModule'
645670 } | Sort-Object Name
@@ -701,32 +726,22 @@ function Update-ModuleList {
701726 }
702727 New-ModuleCatalogPage - Path $modulePagePath - ModuleData $moduleData
703728
704- $moduleTableRows += @"
705- <tr>
706- <td><a href="$modulePageRelativeLink " title="$titleSummary ">$name </a></td>
707- <td><code>$version </code></td>
708- <td><code>$processReference </code><br><sub>$processStatus </sub></td>
709- <td><a href="https://github.com/$owner /$name /issues">$issues </a></td>
710- <td><a href="https://github.com/$owner /$name /pulls">$pullRequests </a></td>
711- <td><a href="https://github.com/$owner /$name /stargazers">$stars </a></td>
712- </tr>
713- "@
729+ $moduleTableRow = $moduleCatalogRowTemplate
730+ $moduleTableRow = $moduleTableRow.Replace (' {{ MODULE_PAGE_LINK }}' , $modulePageRelativeLink )
731+ $moduleTableRow = $moduleTableRow.Replace (' {{ TITLE_SUMMARY }}' , $titleSummary )
732+ $moduleTableRow = $moduleTableRow.Replace (' {{ NAME }}' , $name )
733+ $moduleTableRow = $moduleTableRow.Replace (' {{ VERSION }}' , $version )
734+ $moduleTableRow = $moduleTableRow.Replace (' {{ PROCESS_REFERENCE }}' , $processReference )
735+ $moduleTableRow = $moduleTableRow.Replace (' {{ PROCESS_STATUS }}' , $processStatus )
736+ $moduleTableRow = $moduleTableRow.Replace (' {{ OWNER }}' , $owner )
737+ $moduleTableRow = $moduleTableRow.Replace (' {{ ISSUES }}' , [string ]$issues )
738+ $moduleTableRow = $moduleTableRow.Replace (' {{ PULL_REQUESTS }}' , [string ]$pullRequests )
739+ $moduleTableRow = $moduleTableRow.Replace (' {{ STARS }}' , [string ]$stars )
740+ $moduleTableRows += $moduleTableRow.TrimEnd ()
741+ $moduleTableRows += [Environment ]::NewLine
714742 }
715743
716- $moduleTable = @"
717-
718- <table>
719- <tr>
720- <th width="24%">Name</th>
721- <th width="12%">Version</th>
722- <th width="24%">ProcessVersion</th>
723- <th width="10%">Issues</th>
724- <th width="10%">PRs</th>
725- <th width="10%">Stars</th>
726- </tr>
727- $moduleTableRows </table>
728-
729- "@
744+ $moduleTable = $moduleCatalogTableTemplate.Replace (' {{ ROWS }}' , $moduleTableRows.TrimEnd ())
730745
731746 Update-MDSection - Path ' .\src\docs\Modules\Catalog\index.md' - Name ' MODULE_CATALOG' - Content $moduleTable
732747}
0 commit comments