Bluewaterblog/blog/src/layouts/BlogPostLayout.astro
ebby 5abed41dd6
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
better styling
2026-10-05 19:14:55 +02:00

233 lines
4.2 KiB
Text

---
import { Image } from "astro:assets";
import { findImageByPath } from "../lib/findImage";
import Main from "./Main.astro";
import { formatLocalizedDateString } from "../lib/formatDate";
import type { PostData } from "../content.config";
import NavBack from "../islands/NavBack";
interface Props {
postData: PostData;
}
const { postData } = Astro.props;
const titleImg = findImageByPath(postData.image.path);
const localeDate = formatLocalizedDateString(postData.date);
---
<Main>
<div id="background">
<div id="header">
<Image id="title-img" src={titleImg} alt={postData.image.alt} />
<div class="info">
<span>{localeDate} | </span>
<span>Autor: {postData.author} | </span>
<span>Lesezeit: {postData.time2read} min</span>
</div>
<h1 id="title">{postData.title}</h1>
<h3 id="subtitle">{postData.subtitle}</h3>
<span id="introduction">{postData.introduction}</span>
</div>
<div id="hr-knast">
<hr />
</div>
<article class="markdown-content">
<slot />
<NavBack client:load />
<p class="disclaimer">
Disclaimer: Dieser Artikel ist ausschließlich privat und wird nicht
durch Produktplatzierung, Affiliate-Links oder ähnliches Unterstützt.
Links dienen allein dem Zweck der Information.
</p>
</article>
</div>
<div id="image-backdrop" hidden>
<img id="image-preview" class="rounded" src="" alt="" />
</div>
</Main>
<script is:inline src="/scripts/image-modal.js"></script>
<style>
#background {
display: flex;
align-items: center;
flex-direction: column;
background-image: linear-gradient(
to bottom,
var(--primary-dark),
var(--primary-color)
);
width: 100%;
height: 100%;
padding: 0 20%;
}
#hr-knast {
padding: 16px 64px 0 64px;
background-color: white;
max-width: 900px;
width: 100%;
}
hr {
margin: 0;
height: 1px;
}
#header {
display: flex;
flex-direction: column;
background-color: white;
padding-bottom: 16px;
max-width: 900px;
}
article {
max-width: 900px;
padding: 0 64px;
hyphens: auto;
text-align: justify;
background-color: white;
}
#title-img {
display: block;
width: 100%;
height: 300px;
object-fit: cover;
object-position: center;
order: 1;
}
#header .info,
#header #introduction {
font-size: 1.5rem;
line-height: 1.6;
}
.info {
padding: 32px 64px 0 64px;
font-size: medium;
order: 2;
}
#title {
margin-bottom: 0;
order: 3;
font-size: 2.5rem;
padding: 0 64px;
}
#subtitle {
margin-top: 0;
font-weight: lighter;
order: 4;
font-size: 1.8rem;
padding: 0 64px;
}
#introduction {
padding: 32px 64px 0 64px;
order: 5;
}
.markdown-content {
font-size: 1.5rem;
line-height: 1.6;
img {
cursor: zoom-in;
}
}
.disclaimer {
padding: 64px 0 16px 0;
margin: 0;
font-size: smaller;
}
#image-backdrop {
position: fixed;
inset: 0;
z-index: 1000;
display: grid;
place-items: center;
padding: 24px;
background: rgba(0, 0, 0, 0.8);
cursor: pointer;
}
#image-backdrop[hidden] {
display: none;
}
#image-preview {
max-width: 90vw;
max-height: 90vh;
width: auto;
height: auto;
object-fit: contain;
cursor: pointer;
}
@media only screen and (max-width: 800px) {
.markdown-content {
font-size: 1.25rem;
line-height: 1.4;
background-color: white;
border-radius: 48px 48px 0 0;
}
#hr-knast {
display: none;
}
#background {
padding: 0;
}
#header {
background-color: transparent;
* {
color: white;
}
}
.info {
order: 1;
font-size: 1rem !important;
padding-top: 16px !important;
padding-bottom: 16px;
padding: 0 24px;
}
#title-img {
order: 4;
}
#title {
margin: 0;
order: 2;
padding: 0 24px;
}
#subtitle {
order: 3;
padding: 0 24px;
}
#introduction {
font-size: 1.25rem !important;
order: 5;
padding: 32px 24px 0 24px;
}
article {
padding: 0 24px;
}
}
</style>