Skip to content

Commit 872ea90

Browse files
Version module catalog templates
Store legacy catalog layout as v1 templates, move current layout to v2 templates, and render catalog from v2 templates by default. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent d640330 commit 872ea90

5 files changed

Lines changed: 79 additions & 24 deletions

File tree

.github/actions/update-index/src/Helper.psm1

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
131149
function 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
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<tr>
2+
<td><a href="https://github.com/{{ OWNER }}/{{ NAME }}">{{ NAME }}</a></td>
3+
<td>{{ DESCRIPTION }}
4+
<br>
5+
<a href="https://github.com/{{ OWNER }}/{{ NAME }}/issues">Issues</a> |
6+
<a href="https://github.com/{{ OWNER }}/{{ NAME }}/pulls">PRs</a> |
7+
<a href="https://github.com/{{ OWNER }}/{{ NAME }}/stargazers">Stars</a> |
8+
<a href="https://www.powershellgallery.com/packages/{{ NAME }}/">PS Gallery</a>
9+
</td>
10+
<td><code>{{ VERSION }}</code></td>
11+
</tr>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
<table>
3+
<tr>
4+
<th width="10%">Name</th>
5+
<th width="80%">Description</th>
6+
<th width="10%">Version</th>
7+
</tr>
8+
{{ ROWS }}</table>
9+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<tr>
2+
<td><a href="{{ MODULE_PAGE_LINK }}" title="{{ TITLE_SUMMARY }}">{{ NAME }}</a></td>
3+
<td><code>{{ VERSION }}</code></td>
4+
<td><code>{{ PROCESS_REFERENCE }}</code><br><sub>{{ PROCESS_STATUS }}</sub></td>
5+
<td><a href="https://github.com/{{ OWNER }}/{{ NAME }}/issues">{{ ISSUES }}</a></td>
6+
<td><a href="https://github.com/{{ OWNER }}/{{ NAME }}/pulls">{{ PULL_REQUESTS }}</a></td>
7+
<td><a href="https://github.com/{{ OWNER }}/{{ NAME }}/stargazers">{{ STARS }}</a></td>
8+
</tr>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
<table>
3+
<tr>
4+
<th width="24%">Name</th>
5+
<th width="12%">Version</th>
6+
<th width="24%">ProcessVersion</th>
7+
<th width="10%">Issues</th>
8+
<th width="10%">PRs</th>
9+
<th width="10%">Stars</th>
10+
</tr>
11+
{{ ROWS }}</table>
12+

0 commit comments

Comments
 (0)