SiteMaps.URL (site_maps v0.1.0)

Copy Markdown View Source

A <url> entry of a urlset, validated and normalized by new/2.

Options

  • :lastmod - DateTime, NaiveDateTime (treated as UTC), Date or ISO 8601 string. Omitted when nil; it never defaults to the current time.
  • :changefreq - one of always hourly daily weekly monthly yearly never (atom or string).
  • :priority - a number between 0.0 and 1.0, written with one decimal.
  • :images / :image - one image or a list (up to 1,000). Keys: :loc (required) and the deprecated :caption, :title, :license and :geo_location.
  • :videos / :video - one video or a list. Keys: :thumbnail_loc, :title, :description (required), :content_loc and/or :player_loc (one is required), :allow_embed, :autoplay (a string such as "ap=1"), :duration, :expiration_date, :rating, :view_count, :publication_date, :tags (a string or list of strings, up to 32), :family_friendly, :restriction (%{relationship: :allow | :deny, countries: ["US", ..]}, ISO 3166 codes in upper case), :platform (%{relationship: :allow | :deny, platforms: [:web | :mobile | :tv]}), :requires_subscription, :uploader, :uploader_info, :live and the deprecated :category, :gallery_loc, :gallery_title and :price (%{value: .., currency: "USD", type: :rent | :purchase, resolution: :hd | :sd}, one or a list; :value is a non-negative decimal that requires :currency, and without it :type is required). Booleans are three-state: nil leaves the element out, true/false write yes/no.
  • :news - :publication_name, :publication_language (ISO 639 code of 2 or 3 lower case letters, or zh-cn/zh-tw), :title, :publication_date (required) and the deprecated :access, :genres, :keywords and :stock_tickers.
  • :alternates / :alternate - one or a list of %{href: .., lang: .., media: .., nofollow: bool}, written as <xhtml:link rel="alternate">.
  • :mobile - deprecated, true writes <mobile:mobile/>.
  • :pagemap - deprecated, %{dataobjects: [%{type: .., id: .., attributes: [%{name: .., value: ..}]}]}.

Invalid values raise ArgumentError.

Summary

Functions

Applies fun to every URL-valued nested field: image :loc and :license, video :thumbnail_loc, :content_loc, :player_loc, :gallery_loc and :uploader_info, and alternate :href. The entry loc itself is left untouched.

Builds a validated URL entry. See the module documentation for the options.

Whether the entry carries <news:news>.

Types

changefreq()

@type changefreq() ::
  :always | :hourly | :daily | :weekly | :monthly | :yearly | :never

t()

@type t() :: %SiteMaps.URL{
  alternates: [map()],
  changefreq: changefreq() | nil,
  images: [map()],
  lastmod: DateTime.t() | Date.t() | nil,
  loc: String.t(),
  mobile: boolean(),
  news: map() | nil,
  pagemap: map() | nil,
  priority: float() | nil,
  videos: [map()]
}

Functions

map_locs(url, fun)

@spec map_locs(t(), (String.t() -> String.t())) :: t()

Applies fun to every URL-valued nested field: image :loc and :license, video :thumbnail_loc, :content_loc, :player_loc, :gallery_loc and :uploader_info, and alternate :href. The entry loc itself is left untouched.

new(loc, opts \\ [])

@spec new(String.t(), keyword() | map()) :: t()

Builds a validated URL entry. See the module documentation for the options.

news?(url)

@spec news?(t()) :: boolean()

Whether the entry carries <news:news>.