---
import config from "@/config/config.json";
import Authors from "@/layouts/Authors.astro";
import Base from "@/layouts/Base.astro";
import Pagination from "@/layouts/components/Pagination.astro";
import { getSinglePage } from "@/lib/contentParser.astro";
import { sortByDate } from "@/lib/utils/sortFunctions";
import { markdownify } from "@/lib/utils/textConverter";

const authors = await getSinglePage("authors");
const sortedPosts = sortByDate(authors);
const totalPages = Math.ceil(authors.length / config.settings.pagination);
const currentPosts = sortedPosts.slice(0, config.settings.pagination);
---

<Base title={"Authors"}>
  <section class="section">
    <div class="container text-center">
      <h1 set:text={markdownify("Authors")} class="page-heading h2" />
      <Authors authors={currentPosts} />
      <Pagination section={"authors"} currentPage={1} totalPages={totalPages} />
    </div>
  </section>
</Base>
