@@ -16,9 +16,9 @@ param()
1616# region Core
1717if ($psScriptRoot ) {Push-Location $psScriptRoot }
1818if (-not $Site ) { $Site = [Ordered ]@ {} }
19- $parentFolderManifest =
20- Get-ChildItem - File - Path .. |
21- Where-Object Extension -eq .psd1 |
19+ $parentFolderManifest =
20+ Get-ChildItem - File - Path .. |
21+ Where-Object Extension -eq .psd1 |
2222 Select-String ' ModuleVersion\s{0,}='
2323
2424if ($parentFolderManifest ) {
@@ -65,23 +65,27 @@ if ($site.PSScriptRoot) {
6565 }
6666 $pointer = $pointer [$subdirectory ]
6767 }
68-
68+
6969 $propertyName = $hierarchy [-1 ] -replace ' _' -replace " $ ( [Regex ]::Escape($underbarFile.Extension )) $"
7070
71- $fileData =
72- switch ($underbarFile.Extension ) {
73- ' .ps1' { $ExecutionContext.SessionState.InvokeCommand.GetCommand ($underbarFile.FullName , ' ExternalScript' ) }
74- ' .txt' { Get-Content - LiteralPath $underbarFile.FullName }
75- ' .json' { Get-Content - LiteralPath $underbarFile.FullName - Raw | ConvertFrom-Json }
76- ' .psd1' { Get-Content - LiteralPath $underbarFile.FullName - Raw | ConvertFrom-StringData }
77- ' .yaml' {
78- ' YaYaml' | RequireModule
79- Get-Content - LiteralPath $underbarFile.FullName - Raw | ConvertFrom-Yaml
80- }
81- ' .svg' { (Get-Content - LiteralPath $underbarFile - Raw) -as [xml ] }
82- ' .csv' { Import-Csv - LiteralPath $underbarFile.FullName }
83- ' .tsv' { Import-Csv - LiteralPath $underbarFile.FullName - Delimiter " `t " }
84- }
71+ $getFile = @ {LiteralPath = $underbarFile.FullName }
72+ $fileData =
73+ switch - regex ($underbarFile.Extension ) {
74+ ' \.ps1$' { $ExecutionContext.SessionState.InvokeCommand.GetCommand ($underbarFile.FullName , ' ExternalScript' ) }
75+ ' \.(css|html|txt)$' { Get-Content @getFile }
76+ ' \.json$' { Get-Content @getFile | ConvertFrom-Json }
77+ ' \.jsonl$' { Get-Content @getFile | ConvertFrom-Json }
78+ ' \.psd1$' { Get-Content @getFile - Raw | ConvertFrom-StringData }
79+ ' \.(?>ps1xml|xml|svg)$' { (Get-Content @getFile - Raw) -as [xml ] }
80+ ' \.(?>yaml|toml)$' { Get-Content @getFile - Raw }
81+ ' \.csv$' { Import-Csv @getFile }
82+ ' \.tsv$' { Import-Csv @getFile - Delimiter " `t " }
83+ }
84+ if (-not $fileData ) { continue }
85+ switch ($underbarFile.Extension ) {
86+ .toml { RequireModule PSToml; $fileData = $fileData | ConvertFrom-Toml }
87+ .yaml { RequireModule YaYaml; $fileData = $fileData | ConvertFrom-Yaml }
88+ }
8589
8690 if ($fileData ) {
8791 $pointer [$propertyName ] = $fileData
@@ -138,13 +142,14 @@ if ($site.Module) {
138142 " <pre><code>Import-Module $ ( $site.Module ) </code></pre>"
139143 " <h3>Basics</h3>"
140144 " <pre><code>turtle polygon 42 6</code></pre>"
141- " $ ( turtle polygon 42 6 ) "
142- " <h3>Fractals</h3>"
143- " <pre><code>turtle SierpinskiTriangle 42 3</code></pre>"
144- " $ ( turtle SierpinskiTriangle 42 3 ) "
145- " <h3><a href='/Commands/Get-Turtle'>More Examples</a></h3>"
145+ " $ ( turtle polygon 42 6 ) "
146+ " <h3><a href='/Commands/Get-Turtle'>More Examples</a></h3>"
146147}
147148 ) -join [Environment ]::NewLine
149+ ' Settings' = @ (
150+ . $site.includes.SelectPalette
151+ . $site.includes.GetRandomPalette
152+ )
148153}
149154
150155<# $site.HeaderMenu = [Ordered]@{
0 commit comments