# `Tayori.Router`
[🔗](https://github.com/hattoriai/tayori/blob/v0.1.0/lib/tayori/router.ex#L1)

Mounts Tayori in the app's router.

    import Tayori.Router

    scope "/admin" do
      pipe_through [:browser, :require_admin]

      tayori_admin "/news",
        resolver: MyAppWeb.TayoriResolver,
        on_mount: [{MyAppWeb.AdminAuth, :require_admin}]
    end

    scope "/api" do
      pipe_through :api_session
      tayori_api "/news", resolver: MyAppWeb.TayoriResolver
    end

    scope "/" do
      pipe_through :browser
      tayori_page "/changelog", title: "What's new in MyApp"
    end

`tayori_admin/2` mounts the admin (see the [Admin](admin.md) guide),
`tayori_api/2` the news as JSON, for a frontend that Phoenix does not
render (see [Any frontend](any_frontend.md)), and `tayori_page/2` the
public page and its feeds (see [The public page](public_page.md)). Each
is a library mounted with [PhoenixMountable](https://hexdocs.pm/phoenix_mountable):
ordinary routes in the app's router (`mix phx.routes` lists them),
behind the app's own scopes and pipelines. Every mount also takes the
options of PhoenixMountable: `:as` (to mount one twice), `:on_mount`,
`:socket_path`, `:transport`, `:csp_nonce_assign_key`, `:asset_host`
and `:pubsub`.

The admin is a page of its own, as Lotus's dashboard is: its own
document, script and style sheet, served under the mount with the hash
of the build in their names, so it looks the same in any app.

# `tayori_admin`
*macro* 

Mounts Tayori.Router at `path` in a host router.

    import Tayori.Router

    scope "/" do
      pipe_through :browser
      tayori_admin "/tayori"
    end

## Options

* `:resolver` (`t:atom/0`) - Required. The app's `Tayori.Resolver`: who the admin is, and what they may do.

* `:theme` - The admin's theme: Tayori's own, or Sumi's. The default value is `:tayori`.

* `:page` (`t:String.t/0`) - The path of the public page, for the admin's links to the entries and their previews. By default, the `tayori_page` of the same router.

* `:storage` (`t:atom/0`) - The `Kotoba.Storage` of the attachments of the editor (Kotoba's own config when not given).

Every mount also takes the options listed in `PhoenixMountable`, such as
`:as`, `:on_mount` and `:csp_nonce_assign_key`.

# `tayori_api`
*macro* 

Mounts the news as JSON at `path`: see `Tayori.Router.API` for the
options, and `Tayori.API` for the routes.

# `tayori_page`
*macro* 

Mounts the public page of the news, its entries and its feeds at
`path`: see `Tayori.Router.Page` for the options, and `Tayori.Page`
for the routes.

---

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