packages feed

ema-0.1.0.0: src/Ema/Route.hs

{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeApplications #-}

module Ema.Route
  ( routeUrl,
    routeFile,
    Slug (unSlug),
    UrlStrategy (..),
  )
where

import Data.Default (def)
import Ema.Class
import Ema.Route.Slug (Slug (unSlug))
import Ema.Route.UrlStrategy
  ( UrlStrategy (..),
    slugFileWithStrategy,
    slugUrlWithStrategy,
  )

routeUrl :: forall a r. Ema a r => r -> Text
routeUrl r =
  slugUrlWithStrategy def (encodeRoute @a r)

routeFile :: forall a r. Ema a r => r -> FilePath
routeFile r =
  slugFileWithStrategy def (encodeRoute @a r)