website/src/layouts/Layout.astro
2023-06-19 12:27:53 -04:00

57 lines
1.4 KiB
Text

---
import BaseHead from "../components/BaseHead.astro";
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
const {
frontmatter: { title, description, pubDate, image, author },
} = Astro.props;
---
<script is:inline>
const theme = (() => {
if (typeof localStorage !== "undefined" && localStorage.getItem("theme")) {
return localStorage.getItem("theme");
}
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
return "lunar-witch";
}
return "Bluloco-Zsh-Light";
})();
window.localStorage.setItem("theme", theme);
document.documentElement.classList.add(theme);
</script>
<html lang="en">
<head>
<BaseHead title={title} description={description} />
</head>
<body class="container">
<Header />
<main>
<article>
<div class="article-head">
<h1 class="title">{title}</h1>
<em>Written by: {author}</em>
</div>
<div class="article-body">
{image && <img width={720} height={360} src={image} alt="" />}
Published on: {pubDate && <time>{pubDate}</time>}
<hr />
<slot />
</div>
</article>
</main>
<div class="footer-container">
<Footer />
</div>
<style>
html {
min-height: 100vh;
}
time {
display: inline-block;
margin-top: 10px;
}
</style>
</body>
</html>