summaryrefslogtreecommitdiff
path: root/examples/blog/src/layouts/BlogPost.astro
blob: b8b47bfc09e6b54c81686f8bdbfd2441247e4c8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
import BaseHead from "../components/BaseHead.astro";
import Header from "../components/Header.astro";

export interface Props {
	content: {
		title: string;
		description: string;
		publishDate: string;
		heroImage?: {
			src: string;
			alt: string;
		};
	};
}

const {
	content: { title, description, publishDate, heroImage },
} = Astro.props as Props;
---

<html>
	<head>
		<BaseHead title={title} description={description} />
	</head>

	<body>
		<Header />
		<article class="wrapper content">
			<header>
				{heroImage && (
					<img
						width="720"
						height="420"
						loading="lazy"
						src={heroImage.src}
						alt={heroImage.alt}
					/>
				)}
				<h1 class="title">{title}</h1>
				<time>{publishDate}</time>
			</header>
			<main>
				<slot></slot>
			</main>
		</article>
	</body>
</html>

<style>
	img {
		width: 100vw;
		object-fit: cover;
		object-position: center;
		margin-top: 2rem;
		margin-bottom: 4rem;
		max-width: 1280px;
	}

	@media (max-width: 50em) {
		img {
			height: 260px;
			margin-top: 0;
			margin-bottom: 2rem;
		}
	}

	.content {
		margin-bottom: 8rem;
	}

	.content :global(h2) {
		margin-top: 4rem;
	}

	header {
		display: flex;
		flex-direction: column;
		text-align: center;
		align-items: center;
		justify-content: center;
		gap: 1rem;

		padding-bottom: 2rem;
		margin-bottom: 2rem;
		border-bottom: 4px solid var(--theme-divider);
	}

	.title,
	time {
		margin: 0;
	}

	time {
		color: var(--theme-text-lighter);
	}

	.title {
		font-size: 2.25rem;
		font-weight: 700;
	}
</style>