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

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;
const jsonLd = {
  '@context': 'https://schema.org',
  '@type': 'Blog',
  name: site.title,
  description: site.description,
  url: absoluteUrl('/'),
  inLanguage: site.language
};
---

<!doctype html>
<html lang={site.language}>
  <head>
    <SeoHead title={site.title} description={site.description} path="/" jsonLd={jsonLd} />
  </head>
  <body>
    <Home posts={posts} currentPage={1} totalPages={totalPages} />
  </body>
</html>
