---
import '../../styles/normalize.css';
import DefaultPost from '../../components/DefaultPost.astro';
import YarPost from '../../components/themes/yar/YarPost.astro';
import { site } from '../../lib/siteConfig';

export function getStaticPaths() {
  const modules = import.meta.glob('../../../../../content/posts/*.md', { eager: true });
  return Object.values(modules)
    .filter((post) => post.frontmatter.status === 'published' || post.frontmatter.status === 'archived')
    .map((post) => ({
      params: { slug: post.frontmatter.slug },
      props: { post }
    }));
}

const { post } = Astro.props;
const title = post.frontmatter.title;
const theme = site.theme?.trim().toLowerCase() ?? 'default';
const PostView = theme === 'yar' ? YarPost : DefaultPost;
---

<!doctype html>
<html lang={site.language}>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>{title} | {site.title}</title>
    {post.frontmatter.summary && <meta name="description" content={post.frontmatter.summary} />}
  </head>
  <body>
    <PostView post={post} />
  </body>
</html>
