Skip to main content

lib/crawlberg/article_metadata.ex

# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:06831f8166c6d860691af36ee02b72ae3246568eb2e5c67ed5d11da71d02afeb
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
defmodule Crawlberg.ArticleMetadata do
  @moduledoc "Article metadata extracted from `article:*` Open Graph tags."

  @typedoc "Article metadata extracted from `article:*` Open Graph tags."
  @type t :: %__MODULE__{
          published_time: String.t() | nil,
          modified_time: String.t() | nil,
          author: String.t() | nil,
          section: String.t() | nil,
          tags: [String.t()]
        }

  defstruct published_time: nil,
            modified_time: nil,
            author: nil,
            section: nil,
            tags: []

  defimpl Jason.Encoder do
    @doc false
    def encode(value, opts) do
      value
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> v == nil end)
      |> Enum.into(%{})
      |> Jason.Encoder.encode(opts)
    end
  end
end