extends ../layouts/main
block content

  include ../components/pagination-bar

  section.uk-section.uk-section-default.uk-section-small
    .uk-container

      h1 #{site.name} Newsroom
      if Array.isArray(newsroom.feeds) && (newsroom.feeds.length > 0)
        div(uk-grid).uk-grid-match
          each feed in newsroom.feeds
            div(class="uk-width-1-1 uk-width-1-2@s uk-width-1-3@m uk-width-1-4@l")
              .uk-card.uk-card-secondary.uk-card-small.uk-border-rounded
                .uk-card-header(style="border-bottom: solid 1px #808080;")
                  div(uk-grid).uk-grid-small
                    .uk-width-expand
                      h2.uk-card-title.uk-margin-remove
                        a(href=`/newsroom/${feed._id}`, uk-tooltip=`See all for ${feed.title}`)= feed.title
                    .uk-width-auto
                      a(href=`/newsroom/${feed._id}`, uk-tooltip=`See all for ${feed.title}`).uk-text-small ALL

                  .uk-text-small.uk-text-muted
                    div(uk-grid).uk-grid-collapse.uk-flex-middle
                      if Array.isArray(feed.favicons) && (feed.favicons.length > 0)
                        .uk-width-auto
                          img(src= feed.favicons[0], style="height: 16px; width: auto; margin-right: 6px;")
                      .uk-width-auto
                        div last update #{moment(feed.published).fromNow()}
                    //- div= feed.description

                .uk-card-body
                  if Array.isArray(feed.recent.entries) && (feed.recent.entries.length > 0)
                    ul.uk-list.uk-list-divider
                      each entry in feed.recent.entries
                        li
                          .uk-text-truncate
                            a(href= entry.link, uk-tooltip= entry.title, target="_blank").uk-link-reset= entry.title
                          .uk-article-meta= moment(entry.published).fromNow()

                  else
                    div No recent posts

        .uk-margin
          +renderPaginationBar('/newsroom', newsroom.totalFeedCount)

      else
        div There are no configured news feeds.