Function defaultSocialImage

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

    Example

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

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

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

    Example

    Handle an invalid input string:

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

    Parameters

    • baseURL: string

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

    • folder: string = 'images'

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

    • filename: string = 'socials.png'

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

    Returns Result<string, Error>

    A Result object with either a string representing the default social 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