# `Ltix.DeepLinking.ContentItem.Link`
[🔗](https://github.com/DecoyLex/ltix/blob/main/lib/ltix/deep_linking/content_item/link.ex#L1)

A URL link content item for Deep Linking responses.

Use this for external URLs hosted outside your tool, such as articles,
documentation, or third-party resources. For links that launch back
into your tool via LTI, use `Ltix.DeepLinking.ContentItem.LTIResourceLink`.

## Examples

    iex> {:ok, link} = Ltix.DeepLinking.ContentItem.Link.new(
    ...>   url: "https://example.com/article",
    ...>   window: [target_name: "articles"]
    ...> )
    iex> Ltix.DeepLinking.ContentItem.to_map(link)
    %{"type" => "link", "url" => "https://example.com/article", "window" => %{"targetName" => "articles"}}

## Options

* `:title` (`t:String.t/0`) - Title for the content item.

* `:text` (`t:String.t/0`) - Plain-text description.

* `:extensions` (`nil` | `t:map/0`) - Required. Vendor-specific extension properties. The default value is `%{}`.

* `:embed` (`t:map/0`)

* `:url` (`t:String.t/0`) - Required. URL of the link.

* `:icon` (`t:map/0`) - Icon or thumbnail for the link.

* `:thumbnail` (`t:map/0`) - Icon or thumbnail for the link.

* `:window` (`t:map/0`) - Window presentation for the link.

* `:iframe` (`t:map/0`) - Iframe presentation for the link.

# `t`

```elixir
@type t() :: %Ltix.DeepLinking.ContentItem.Link{
  embed: nil | %{html: binary()},
  extensions: nil | %{optional(binary() | atom()) =&gt; any()},
  icon:
    nil
    | %{
        optional(:width) =&gt; integer(),
        :url =&gt; binary(),
        optional(:height) =&gt; integer()
      },
  iframe:
    nil
    | %{
        optional(:width) =&gt; integer(),
        optional(:height) =&gt; integer(),
        src: binary()
      },
  text: nil | binary(),
  thumbnail:
    nil
    | %{
        optional(:width) =&gt; integer(),
        :url =&gt; binary(),
        optional(:height) =&gt; integer()
      },
  title: nil | binary(),
  url: binary(),
  window:
    nil
    | %{
        optional(:width) =&gt; integer(),
        optional(:height) =&gt; integer(),
        optional(:target_name) =&gt; binary(),
        optional(:window_features) =&gt; binary()
      }
}
```

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | {:error, Exception.t()}
```

Create a new link content item.

Takes the module's options as a keyword list or map, and nested options such as
`icon` may also be keyword lists. Unknown or invalid options return an
`Ltix.Errors.Invalid.InvalidField` error.

## Examples

    iex> {:ok, link} = Ltix.DeepLinking.ContentItem.Link.new(url: "https://example.com")
    iex> link.url
    "https://example.com"

    iex> {:error, error} = Ltix.DeepLinking.ContentItem.Link.new([])
    iex> Exception.message(error)
    "Ltix.DeepLinking.ContentItem.Link field :url is required [DL §3.1]"

# `new!`

```elixir
@spec new!(keyword() | map()) :: t()
```

Same as `new/1` but raises on error.

## Examples

    iex> Ltix.DeepLinking.ContentItem.Link.new!(url: "https://example.com").url
    "https://example.com"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
