|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | + Project CHANGELOG |
| 4 | +.DESCRIPTION |
| 5 | + The CHANGELOG for the project |
| 6 | +.NOTES |
| 7 | + The CHANGELOG is a record of major changes and releases for the project. |
| 8 | +#> |
1 | 9 | param( |
| 10 | +# We can provide the repository url by hard-coding it, or it can be provided in site or page metadata. |
2 | 11 | [uri] |
3 | 12 | $RepositoryUrl = "https://github.com/PowerShellWeb/Turtle", |
4 | 13 |
|
| 14 | +# We can provide the changelog path by hard-coding it, or it can provided in site or page metadata. |
5 | 15 | [string] |
6 | 16 | $ChangeLogPath = '../CHANGELOG.md' |
7 | 17 | ) |
| 18 | + |
| 19 | + |
| 20 | +# Push into this location, in case we are building this file interactively. |
8 | 21 | if ($PSScriptRoot) { Push-Location $PSScriptRoot} |
9 | | -"<style>" |
10 | | -".viewSource {float: right;}" |
11 | | -"</style>" |
12 | | -"<details class='viewSource'>" |
13 | | -"<summary>View Source</summary>" |
14 | | -"<pre><code class='language-PowerShell'>" |
15 | | -[Web.HttpUtility]::HtmlEncode($MyInvocation.MyCommand.ScriptBlock) |
16 | | -"</code></pre>" |
| 22 | + |
| 23 | +# Get my own help |
| 24 | +$myHelp = Get-Help $MyInvocation.MyCommand.ScriptBlock.File |
| 25 | +if ($myHelp) { |
| 26 | + # If we have page metadata |
| 27 | + if ($page -is [Collections.IDictionary]) { |
| 28 | + # Replace 'Project' in the title with the url, to make the title and description more helpful |
| 29 | + $page.Title = $myHelp.SYNOPSIS -replace 'Project', { |
| 30 | + $RepositoryUrl.Segments[-1] -replace '/' |
| 31 | + } |
| 32 | + $page.Description = $myHelp.Description.text -join [Environment]::NewLine -replace 'The Project', { |
| 33 | + $RepositoryUrl.Segments[-1] -replace '/' |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + # If we have notes, replace the project with our name |
| 38 | + $myNotes = $myHelp.alertSet.alert.text -join [Environment]::NewLine -replace 'The Project', { |
| 39 | + $RepositoryUrl.Segments[-1] -replace '/' |
| 40 | + } |
| 41 | + if ($myNotes) { |
| 42 | + # and convert our notes from markdown. |
| 43 | + (ConvertFrom-Markdown -InputObject $myNotes).Html |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +# Break up the space a bit with horizontal rules. |
| 48 | + |
| 49 | +"<hr/>" |
| 50 | +# Display source for this page |
| 51 | +"<details>" |
| 52 | + "<summary>View Source</summary>" |
| 53 | + "<pre>" |
| 54 | + "<code class='language-PowerShell'>" |
| 55 | + [Web.HttpUtility]::HtmlEncode($MyInvocation.MyCommand.ScriptBlock) |
| 56 | + "</code>" |
| 57 | + "</pre>" |
17 | 58 | "</details>" |
| 59 | + |
| 60 | +# Break up the space a bit with horizontal rules. |
| 61 | +"<hr/>" |
| 62 | + |
| 63 | +# Get our changelog |
18 | 64 | (Get-ChildItem -Path $ChangeLogPath | |
19 | | - ConvertFrom-Markdown | |
| 65 | + ConvertFrom-Markdown | # and convert it from markdown |
| 66 | + # Then, replace issue links |
20 | 67 | Select-Object -ExpandProperty HTML) -replace '(?<=[\(\,)]\s{0,})\#\d+', { |
21 | 68 | $match = $_ |
22 | 69 | if ($RepositoryUrl) { |
| 70 | + # with actual links to the issues. |
23 | 71 | $issueNumber = $($match -replace '\#' -as [int]) |
24 | 72 | "<a href='$RepositoryUrl/issues/$issueNumber'>" + "#$issueNumber" + "</a>" |
25 | 73 | } else { |
26 | 74 | "$match" |
27 | 75 | } |
28 | 76 | } |
| 77 | + |
| 78 | +# If we pushed into the location, pop back out. |
29 | 79 | if ($PSScriptRoot) { Pop-Location} |
| 80 | + |
| 81 | +# We're done! |
0 commit comments