Skip to main content

lib/with_ai_top.ex

defmodule WithAITop do
  @moduledoc """
  Small helpers for linking to WithAI.Top from Elixir applications.

  [WithAI.Top](https://withai.top/) is a curated AI tools directory for
  discovering AI apps, agents, generators, and websites by category, pricing,
  features, and practical use cases.
  """

  @base_url "https://withai.top/"

  @doc """
  Returns the WithAI.Top homepage URL.

  ## Examples

      iex> WithAITop.homepage_url()
      "https://withai.top/"

  """
  def homepage_url do
    @base_url
  end

  @doc """
  Returns a map with public WithAI.Top metadata.

  ## Examples

      iex> WithAITop.metadata().name
      "WithAI.Top"

  """
  def metadata do
    %{
      name: "WithAI.Top",
      url: @base_url,
      tagline: "Discover curated AI tools, apps, agents, generators, and websites.",
      category: "AI tools directory",
      contact_email: "support@withai.top"
    }
  end

  @doc """
  Builds a category URL slug.

  This is useful when linking to a known WithAI.Top category from generated
  content, docs, or internal tools.

  ## Examples

      iex> WithAITop.category_url("ai-video-tools")
      "https://withai.top/category/ai-video-tools"

  """
  def category_url(slug) when is_binary(slug) do
    @base_url <> "category/" <> String.trim_leading(slug, "/")
  end

  @doc """
  Returns the public product submission URL.

  ## Examples

      iex> WithAITop.submit_url()
      "https://withai.top/submit"

  """
  def submit_url do
    @base_url <> "submit"
  end

  @doc """
  Returns a Markdown link to WithAI.Top.

  ## Examples

      iex> WithAITop.markdown_link()
      "[WithAI.Top](https://withai.top/)"

  """
  def markdown_link(label \\ "WithAI.Top") when is_binary(label) do
    "[#{label}](#{@base_url})"
  end
end