|
| 1 | +$sitePath = Join-Path ($PSScriptRoot | Split-Path) 'docs' |
| 2 | + |
| 3 | +$sourceModule = Get-Module PSJekyll |
| 4 | +if (-not $sourceModule) { |
| 5 | + $sourceModule = Import-Module ($PSScriptRoot | Split-Path) -PassThru |
| 6 | +} |
| 7 | + |
| 8 | + |
| 9 | +Push-Location $sitePath |
| 10 | +$PSJekyll.CurrentSite.Domain = "websocket.powershellweb.com" |
| 11 | +$PSJekyll.CurrentSite.Data = @{LastDateBuilt = [datetime]::UtcNow.Date.ToString('yyyy-MM-dd')} |
| 12 | +$PSJekyll.CurrentSite.Data = @{ |
| 13 | + "PSModule/Info" = $sourceModule | |
| 14 | + Select-Object -Property Name, |
| 15 | + Version, |
| 16 | + Description, |
| 17 | + Copyright, |
| 18 | + CompanyName, |
| 19 | + Author, |
| 20 | + @{ |
| 21 | + Name = 'Tags' |
| 22 | + Expression = { @($_.PrivateData.PSData.Tags | Select-Object -Unique)} |
| 23 | + } |
| 24 | + "PSModule/Exports" = @( |
| 25 | + foreach ($command in $sourceModule.ExportedCommands.Values) { |
| 26 | + [Ordered]@{ |
| 27 | + Name = $command.Name |
| 28 | + CommandType = $command.CommandType |
| 29 | + Definition = $command.Definition |
| 30 | + ParameterName = $command.Parameters.Keys |
| 31 | + Parameter = @( |
| 32 | + $command.Parameters.Values | |
| 33 | + Select-Object -Property Name, |
| 34 | + @{ |
| 35 | + Name='ParameterType' |
| 36 | + Expression = { $_.ParameterType.ToString() } |
| 37 | + }, |
| 38 | + Position, |
| 39 | + Mandatory, |
| 40 | + ValueFromPipeline, |
| 41 | + ValueFromPipelineByPropertyName, |
| 42 | + ValueFromRemainingArguments, |
| 43 | + HelpMessage |
| 44 | + ) |
| 45 | + } |
| 46 | + } |
| 47 | + ) |
| 48 | + |
| 49 | + "PSModule/FunctionNames" = $sourceModule.ExportedFunctions.Keys |
| 50 | + "PSModule/CmdletNames" = $sourceModule.ExportedCmdlets.Keys |
| 51 | + "PSModule/AliasNames" = $sourceModule.ExportedAliases.Keys |
| 52 | + "PSModule/Aliases" = @($sourceModule.ExportedAliases.Values | |
| 53 | + ForEach-Object { [Ordered]@{Name=$_.Name;Definition=$_.Definition} }) |
| 54 | + |
| 55 | + "PSModule/VariableNames" = $sourceModule.ExportedVariables.Keys |
| 56 | + "PSModule/TypeNames" = $sourceModule.ExportedTypeFiles | |
| 57 | + ForEach-Object { (Select-Xml -XPath //Types/Type -Path $_).Node.Name } |
| 58 | + |
| 59 | +} |
| 60 | +$PSJekyll.CurrentSite.Data |
| 61 | +# It is important to use [Ordered], otherwise, the order of the keys will be random. |
| 62 | +# (this will generate more changes than necessary in the git repository, and will be noisier than desired) |
| 63 | +$PSJekyll.CurrentSite.Config = [Ordered]@{ |
| 64 | + title = "WebSocket" |
| 65 | + description = "Work with WebSockets in PowerShell" |
| 66 | + url = "https://websocket.powershellweb.com" |
| 67 | + permalink = 'pretty' |
| 68 | + palette = 'Konsolas' |
| 69 | + analyticsId = 'G-R5C30737B2' |
| 70 | + googleFont = 'Noto Sans' |
| 71 | + stylesheet = 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' |
| 72 | + defaults = @([Ordered]@{ |
| 73 | + values = @{layout='Default'} |
| 74 | + }) |
| 75 | +} |
| 76 | +$PSJekyll.CurrentSite.Config |
| 77 | + |
| 78 | +foreach ($templateMember in $PSJekyll.Template.psobject.Members) { |
| 79 | + if ($templateMember.Name -notmatch '^(?>layout|include)\p{P}{0,}') { |
| 80 | + continue |
| 81 | + } |
| 82 | + $templateFileType = $matches.0 -replace '\p{P}{0,}$' |
| 83 | + $templateFileName = $templateMember.Name -replace "^$([Regex]::Escape($templateFileType))\p{P}{0,}" |
| 84 | + |
| 85 | + if ($templateMember.Name -notmatch '\.([^\.]+?)$') { |
| 86 | + $templateFileName += '.html' |
| 87 | + } |
| 88 | + $templateOut = |
| 89 | + if ($templateMember.Invoke) { |
| 90 | + $templateMember.Invoke() |
| 91 | + } else { |
| 92 | + $templateMember.Value |
| 93 | + } |
| 94 | + try { |
| 95 | + $PSJekyll.CurrentSite.$templateFileType = $templateFileName, $templateOut |
| 96 | + } catch { |
| 97 | + $err = $_ |
| 98 | + Write-Error -Message "Failed to set $templateFileName of $templateFileType : $err" |
| 99 | + } |
| 100 | +} |
| 101 | + |
| 102 | +$PSJekyll.CurrentSite.Page = 'Tree', "{% include SiteTree.html %}" |
| 103 | +$PSJekyll.CurrentSite.Page = 'Repos', "{% include Repos.md %}" |
| 104 | +$PSJekyll.CurrentSite.Page = 'Releases', "{% include Releases.md %}" |
| 105 | +$PSJekyll.CurrentSite.Page = 'Contibutors', "{% include Contributor.md %}" |
| 106 | +$PSJekyll.CurrentSite.Page = 'Members', "{% include OrgMember.md %}" |
| 107 | +$PSJekyll.CurrentSite.Page = 'Function', "{% include PSFunctions.md %}" |
| 108 | +$PSJekyll.CurrentSite.Page = 'Functions', "{% include PSFunctions.md %}" |
| 109 | +$PSJekyll.CurrentSite.Page = 'Alias', "{% include PSAlias.md %}" |
| 110 | +$PSJekyll.CurrentSite.Page = 'Aliases', "{% include PSAlias.md %}" |
| 111 | +$PSJekyll.CurrentSite.Page = 'Cmdlet', "{% include PSCmdlet.md %}" |
| 112 | +$PSJekyll.CurrentSite.Page = 'Cmdlets', "{% include PSCmdlet.md %}" |
| 113 | +$PSJekyll.CurrentSite.Page = 'PSTag', "{% include PSTag.md %}" |
| 114 | +$PSJekyll.CurrentSite.Page = 'PSTypeName', "{% include PSTypeName.md %}" |
| 115 | +$PSJekyll.CurrentSite.Layout |
| 116 | +$PSJekyll.CurrentSite.Include |
| 117 | +$PSJekyll.CurrentSite.Page |
| 118 | + |
| 119 | +Pop-Location |
0 commit comments