noway.moe/src/layouts/BlogPost.astro

138 lines
4.2 KiB
Text

---
import type { CollectionEntry } from 'astro:content';
import BaseHead from '../components/BaseHead.astro';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import FormattedDate from '../components/FormattedDate.astro';
import { Code } from 'astro:components';
type Props = CollectionEntry<'blog'>['data'];
const { title, description, pubDate, updatedDate, heroImage } = Astro.props;
---
<html lang="en">
<head>
<BaseHead title={title} description={description} />
<style is:inline>
main {
max-width: 900px;
margin: auto;
}
div.markdown-title {
text-align: center;
margin-bottom: 20px;
}
h1.markdown-title {
font-family: PoetsenOne, var(--font-sans);
font-size: 60px;
}
.hero-image {
width: 100%;
}
.hero-image img {
display: block;
margin: 30px auto;
border-radius: 22px;
filter: drop-shadow(0 4px 6px #000);
}
.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
margin-top: calc(var(--font-size) / 3);
font-family: PoetsenOne, var(--font-sans);
text-align: left;
}
.prose h1 {
font-size: 60px;
border-bottom: 2px solid #000;
margin-bottom: calc(var(--font-size) / 3);
}
.prose h2 {
font-size: 40px;
border-bottom: 1px solid #aaa;
}
.prose h3 {
font-size: 30px;
}
.prose h4, .prose h5, .prose h6 {
font-size: 22px;
}
.prose p {
line-height: 1.5;
font-family: var(--font-sans);
margin: 16px 0;
}
.prose ul {
padding-left: 30px;
}
.prose li {
list-style-type: disc;
}
.prose img {
display: block;
margin: 30px auto;
border-radius: 22px;
filter: drop-shadow(0 4px 6px #444);
}
.prose pre {
background-color: #f6f6f6;
border-radius: 6px;
padding: 16px;
margin: 16px 0;
font-family: var(--font-mono);
filter: drop-shadow(0 2px 6px #ddd);
}
.prose pre > code[data-line-numbers] {
counter-reset: line;
}
.prose pre > code[data-line-numbers] > .line::before {
counter-increment: line;
content: counter(line);
display: inline-block;
margin-right: 2rem
width: 1rem;
text-align: left;
color: #7ca2dfad;
}
.prose pre > code > .line::before {
content: "";
display: inline-block;
width: 1rem;
text-align: right;
}
</style>
</head>
<body>
<Header />
<main>
<article>
<div class="markdown-title">
<h1 class="markdown-title">{title}</h1>
<div class="date">
<FormattedDate date={pubDate} />
{
updatedDate && (
<div class="last-updated-on">
Last updated on <FormattedDate date={updatedDate} />
</div>
)
}
</div>
</div>
<div class="prose">
<div class="hero-image">
{heroImage && <img width={1020} height={510} src={heroImage} alt="" />}
</div>
<slot />
</div>
</article>
</main>
<Footer />
</body>
</html>