# `SiteMaps.Config`
[🔗](https://github.com/marcosgz/site_maps_ex/blob/v0.1.0/lib/site_maps/config.ex#L1)

Validated configuration of a sitemap module. Options are given to `use SiteMaps`, read from the
application environment when `:otp_app` is set, and returned by the optional
`c:SiteMaps.config/1` callback, in that order of precedence, later sources winning.

## Options

* `:url` - Required. Public URL of the sitemap index. Ending in `.xml.gz` gzips every file.

* `:adapter` - Required. Storage adapter, `Module` or `{Module, opts}`.

* `:max_links` - URLs per sitemap file. The default value is `50000`.

* `:max_bytes` - Uncompressed bytes per sitemap file. The default value is `50000000`.

* `:max_news` - News URLs per sitemap file. The default value is `1000`.

* `:max_index_links` - Entries in the index. The default value is `50000`.

* `:default_changefreq` - `<changefreq>` for URLs without one. The default value is `nil`.

* `:default_priority` - `<priority>` for URLs without one. The default value is `nil`.

* `:xsl_stylesheet_url` - XSL stylesheet of urlsets. The default value is `nil`.

* `:xsl_index_stylesheet_url` - XSL stylesheet of the index. The default value is `nil`.

* `:cache_control` - Cache-Control stored with files. The default value is `"public, max-age=3600"`.

* `:max_concurrency` - Processes run in parallel. Defaults to schedulers online. The default value is `nil`.

* `:tmp_dir` - Directory for files being built. Defaults to `System.tmp_dir!/0`. The default value is `nil`.

# `t`

```elixir
@type t() :: %SiteMaps.Config{
  adapter: {module(), keyword()},
  cache_control: String.t() | nil,
  default_changefreq: atom() | nil,
  default_priority: float() | nil,
  gzip?: boolean(),
  index_key: String.t(),
  max_bytes: pos_integer(),
  max_concurrency: pos_integer(),
  max_index_links: pos_integer(),
  max_links: pos_integer(),
  max_news: pos_integer(),
  root_uri: URI.t(),
  tmp_dir: Path.t(),
  url: String.t(),
  xsl_index_stylesheet_url: String.t() | nil,
  xsl_stylesheet_url: String.t() | nil
}
```

# `key_to_url`

```elixir
@spec key_to_url(t(), String.t()) :: String.t()
```

Absolute URL of the file stored under `key`.

# `new!`

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

Validates `opts` and builds the configuration. Raises on invalid options.

# `resolve_loc`

```elixir
@spec resolve_loc(t(), String.t()) :: String.t()
```

Resolves a path against the site origin. Absolute `http(s)` URLs are returned unchanged.

# `url_to_key`

```elixir
@spec url_to_key(t(), String.t()) :: {:ok, String.t()} | :error
```

Storage key of `url`, or `:error` when the URL is outside the sitemap directory.

---

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