---
import '../styles/normalize.css';
import DefaultHome from '../components/DefaultHome.astro';
import YarHome from '../components/themes/yar/YarHome.astro';
import { site } from '../lib/siteConfig';
import { getPaginatedPosts, getPublishedPosts, getTotalPages } from '../lib/posts';

const allPosts = getPublishedPosts();
const posts = getPaginatedPosts(allPosts, 1);
const totalPages = getTotalPages(allPosts);
const theme = site.theme?.trim().toLowerCase() ?? 'default';
const Home = theme === 'yar' ? YarHome : DefaultHome;
---

<!doctype html>
<html lang={site.language}>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>{site.title}</title>
    <meta name="description" content={site.description} />
  </head>
  <body>
    <Home posts={posts} currentPage={1} totalPages={totalPages} />
  </body>
</html>
