base/src/sqwl/cms/layout/ArticlesInCategory.scala
author Tomas Zeman <tzeman@volny.cz>
Thu, 13 Dec 2018 15:15:13 +0100
changeset 19 83fb90bdd15b
parent 12 e7512f9dc903
permissions -rw-r--r--
Rendering of tags and lists of articles

package sqwl.cms.layout

import scalatags.Text.all._
import scalatags.Text.{TypedTag, tags2}
import sqwl.cms._

object ArticlesInCategory extends config {
  def apply(cnt: iContent, st: ViewState): Option[TypedTag[String]] =
    st match {
      case ViewCategory(c) =>
        val l = cnt.articlesByCategory(c)
        Some(tags2.section(
          div(cls:="list-group", l.map(art =>
            a(href:=s"/${http.prefix}/${art.pathSegment}",
              cls:="list-group-item", art.title)
          )),
          if (l.isEmpty) "V této kategorii není ještě článek." else ""
      ))
      case _ => None
    }
}