@@ -169,23 +169,7 @@ $pagesByUrl = $site.PagesByUrl
169169 $title = $Page [' title' ] = $file.Name -replace ' \..+?\.ps1$' -replace ' index'
170170
171171 # region Map File Parameters to Page and Site configuration
172- $FileParameters = [Ordered ]@ {}
173- :nextParameter foreach ($parameterName in $scriptCmd.Parameters.Keys ) {
174- $parameter = $scriptCmd.Parameters [$parameterName ]
175- $potentialType = $parameter.ParameterType
176- foreach ($PotentialName in
177- @ ($parameter.Name ;$parameter.Aliases ) -ne ' '
178- ) {
179- if ($page [$potentialName ] -and $page [$potentialName ] -as $potentialType ) {
180- $FileParameters [$potentialName ] = $page [$potentialName ]
181- continue nextParameter
182- }
183- elseif ($site [$potentialName ] -and $site [$potentialName ] -as $potentialType ) {
184- $FileParameters [$potentialName ] = $site [$potentialName ]
185- continue nextParameter
186- }
187- }
188- }
172+ $FileParameters = $scriptCmd | splat $Site $Page
189173 try {
190174 $description = ' '
191175 . $file @FileParameters
@@ -259,60 +243,7 @@ $pagesByUrl = $site.PagesByUrl
259243 # This is somewhat straightforward, and opens up a lot of doors.
260244 # By allowing information in page or site to pass down to any command,
261245 # we can easily extend sites with simple scripts, and seamlessly integrate them.
262- $layoutParameters = $layoutAtPathParameters [$fileRoot ] = [Ordered ]@ {}
263-
264- # We have to walk over every parameter.
265- # Since we want to exit the loop as soon as we have mapped a parameter,
266- # we use a loop label, `:nextParameter`.
267- :nextParameter foreach ($parameterName in $layoutCommand.Parameters.Keys ) {
268- $parameter = $layoutCommand.Parameters [$parameterName ]
269- $potentialType = $parameter.ParameterType
270- # PowerShell parameters can have aliases, so lets find all potential names.
271- $parameterNames = @ ($parameter.Name ;$parameter.Aliases ) -ne ' '
272- foreach ($PotentialName in $parameterNames ) {
273- # If the page has the parameter
274- if ($page [$potentialName ] -and
275- # and it is the right type
276- $page [$potentialName ] -as $potentialType
277- ) {
278- # We map the parameter from the page data.
279- $layoutParameters [$potentialName ] = $page [$potentialName ]
280-
281- # We want to merge any dictionaries in both `$site` and `$page`.
282- if ($site [$potentialName ] -and
283- $site [$potentialName ] -as $potentialType -and
284- $site [$potentialName ] -is [Collections.IDictionary ] -and
285- $page [$potentialName ] -is [Collections.IDictionary ]
286- ) {
287- # We copy in site wide data first.
288- # This will show site-wide entries
289- $layoutParameters [$potentialName ] = [Ordered ]@ {}
290- foreach ($siteKey in $site [$potentialName ].Keys) {
291- $layoutParameters [$PotentialName ][$siteKey ] = $site [$potentialName ][$SiteKey ]
292- }
293- # before page-specific entries.
294- # An entry in pages would overwrite an entry in the site.
295- foreach ($pageKey in $page [$potentialName ].Keys) {
296- $layoutParameters [$potentialName ][$pageKey ] = $page [$potentialName ][$pageKey ]
297- }
298- }
299- # Now that we've mapped this parameter, continue to the `nextParameter`.
300- continue nextParameter
301- }
302-
303-
304- if (
305- # If we have the layout parameter in the `$site`
306- $site [$potentialName ] -and
307- # and it can be the right type
308- $site [$potentialName ] -as $potentialType
309- ) {
310- # Map it, and continue to the next parameter.
311- $layoutParameters [$potentialName ] = $site [$potentialName ]
312- continue nextParameter
313- }
314- }
315- }
246+ $layoutParameters = $layoutCommand | splat $site $page
316247 }
317248 # endregion Prepare Layout
318249
0 commit comments