Function defaultImage

  • Generates a default image URL by concatenating the base URL, folder, and filename.

    Example

    defaultImage('https://www.example.com')
    // => { ok: true, value: 'https://www.example.com/images/logos/logo.png' }

    defaultImage('https://www.example.com', 'assets')
    // => { ok: true, value: 'https://www.example.com/assets/logo.png' }

    Example

    Handle an invalid input string:

    defaultSocialImage(null)
    // => { ok: false, error: Error('[urls.defaultImage] Expected string values for all parameters') }

    Parameters

    • baseURL: string

      The base URL to be used for generating the default image URL.

    • folder: string = 'images/logos'

      The folder path to be appended to the base URL. Defaults to 'images/logos'.

    • filename: string = 'logo.png'

      The filename to be appended to the base URL and folder. Defaults to 'logo.png'.

    Returns Result<string, Error>

    A Result object containing a string representing the default image URL if all inputs are valid strings, or an Error object if any of the inputs are not valid strings.

Generated using TypeDoc v0.24.7