Templates/New-ITIDocsSiteTemplate.ps1

<#
.SYNOPSIS
    Creates DocsSite repository structure according to the IT integro project template
 
.DESCRIPTION
    This function creates folders structure, setup files and article template files for product docs site
 
.EXAMPLE
    New-ITIDocsSiteTemplate -ProductName YourProductName -ProductTradeName 'Your Product Trade Name' -Location ~/Desktop/MyProject
 
.NOTES
    The template includes two language subfolders, pl-pl and en-us. Each subfolder includes:
    - docfx.json - docfx configuration file
    - index.md - home page source file
    - .gitignore - gitignore for temp _site folder
    Product docs site directory - for storing product documentation articles
    Scripts directory - for storing build scripts and CI pipeline specification
#>

function New-ITIDocsSiteTemplate {
    [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')]
    param (
        # Product name
        [Parameter(Mandatory=$true)]
        [string] $ProductName,
        # Product trade name
        [Parameter(Mandatory=$true)]
        [string] $ProductTradeName,     
        # Specifies the directory where the docs site template will be created
        [string] $Location = './'
    )
    $ProductNamePattern = 'ProductName'

    if (-Not(Test-Path $Location)) {
        New-Item -Path $Location -ItemType Directory
    }
    Copy-DirectoryContent -SourceFolder (Join-Path $PSScriptRoot 'DocsSite') -Destination $Location
    Get-ChildItem $Location -File -Recurse | 
    Foreach-Object {
        Update-FileContent -FilePath $_.FullName -SearchString $ProductNamePattern -RenameToString $ProductName
        Update-FileContent -FilePath $_.FullName -SearchString 'ProductTradeName' -RenameToString $ProductTradeName
    }
    Get-ChildItem $Location -Directory -Recurse | 
    Where-Object {$_.Name -match $ProductNamePattern} | 
    Rename-Item -NewName { $_.Name -replace $ProductNamePattern,$ProductName }
}

Export-ModuleMember -Function New-ITIDocsSiteTemplate