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