UDTruncateText.psm1

$IndexJs = Get-ChildItem "$PSScriptRoot\index.*.bundle.js"
$AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($IndexJs.FullName)

function New-UDTruncateText {
    <#
    .SYNOPSIS
    Gives the ability to decide how much text to display
    
    .DESCRIPTION
    Allows you to decide how many lines of text you wish to display then provide a hyperlink for the end-user to carry on reading the article
    
    .PARAMETER Id
    The ID of this editor

    .PARAMETER Hyperlink
    Set the hyperlink to point to the main article

    .PARAMETER Lines
    Set the number of lines you want to return to the end user before the text is truncated

    .PARAMETER TruncateText
    Displays the truncation text which is defaulted to ...

    .PARAMETER ReadOn
    Text for the hyperlink at the end of the truncation defaulted to Read On

    .PARAMETER Text
    Text for the component

    .EXAMPLE
    New-UDTruncateText -HyperLink "https://adam-bacon.netlify.app/recent-modules/udtextfit/" -Lines 2 -ReadOn "Read More Here" -Text "So this is a super important bit of text you need to read, but do not want to ramble on too long so have a link to encourage the user to read the main article"
    #>

    
    param(
        [Parameter()]
        [string]$Id = (New-Guid).ToString(),
        [Parameter()]
        [int]$Lines,
        [Parameter()]
        [string]$Text,
        [Parameter()]
        [string]$TruncateText = "...",
        [Parameter()]
        [string]$HyperLink,
        [Parameter()]
        [string]$ReadOn = "Read On"
    )

    End {
        @{
            assetId = $AssetId 
            isPlugin = $true 
            type = "udtruncatetext"
            id = $Id

            line = $Lines
            truncateText = $TruncateText
            text = $Text
            href = $HyperLink
            readon = $ReadOn
        }
    }
}