Types/OpenPackage.Publisher/Site.ps1
|
<# .SYNOPSIS Publishes a static site .DESCRIPTION Publishes a package as a static site. .NOTES This installs the package to the -DestinationPath (default `./_site`) #> [CmdletBinding(PositionalBinding=$false,SupportsShouldProcess)] param( # The destination path of the website. [Parameter(Position=0)] [string] $DestinationPath = './_site', # Any input object. This should be one or more packages. # If no input is provided, will archive the current directory and publish a page. [Parameter(ValueFromPipeline)] [Alias('Package')] [PSObject[]] $InputObject ) # Quickly enumerate all input and arguments. $allInput = @($input) if (-not $allInput -and $InputObject) { $allInput += $InputObject } # If there is no input if (-not $allInput) { # exclude our destination from the input $excludeWildCard = $DestinationPath -replace './', '*' -replace '$', '*' # and make a package from the current directory. $allInput = @(Get-OpenPackage -FilePath . -Exclude $excludeWildCard) } # Still no input? Return. if (-not $allInput) { return } # To build a static site out of a package, we just need to install it $installParameters = [Ordered]@{ DestinationPath = $DestinationPath Force = $true WarningAction = 'SilentlyContinue' WarningVariable = 'warnings' } # All of the content from that site is the base layer $allInput | Install-OpenPackage @installParameters -PassThru -Force |