Skip to content

Commit 4cc1b49

Browse files
committed
Improve prose & image styling
1 parent 2fd9252 commit 4cc1b49

File tree

10 files changed

+35
-15
lines changed

10 files changed

+35
-15
lines changed

astro.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export default defineConfig({
66
image: {
77
responsiveStyles: true,
88
layout: 'constrained',
9+
objectFit: 'scale-down',
10+
objectPosition: 'center',
911
breakpoints: [400, 640, 750, 828, 1080, 1280, 1668, 2048, 2560],
1012
},
1113
});

src/components/BlogPost.astro

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
import '../styles/prose.scss';
3+
24
import { render, type CollectionEntry } from 'astro:content'
35
import formatDate from '../util/formatDate';
46
import TagCluster from './TagCluster.astro';
@@ -19,11 +21,11 @@ const { Content } = await render(post);
1921
<h1>{post.data.title}</h1>
2022
<p>{pubDate}</p>
2123
{post.data.cover !== undefined &&
22-
<Image src={post.data.cover} alt={post.data.coverAlt ?? null} />
24+
<Image class="cover" src={post.data.cover} alt={post.data.coverAlt ?? null} />
2325
}
2426
<TagCluster />
2527
</header>
26-
<div class="content">
28+
<div class="prose">
2729
<Content />
2830
</div>
2931
</article>
@@ -51,8 +53,4 @@ const { Content } = await render(post);
5153
margin: 0;
5254
}
5355
}
54-
55-
.content {
56-
line-height: $size-xl;
57-
}
5856
</style>

src/components/TagCluster.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212

1313
li {
1414
display: inline-block;
15-
margin: 0;
1615
padding: $space-sm;
1716

1817
border: $border-thickness solid $color-subtle;
1918
border-radius: $border-radius;
20-
box-shadow: 0 $border-thickness $color-subtle;
19+
box-shadow: 0 2px $color-subtle;
2120
}
2221
}
2322
</style>
2.49 MB
Loading
601 KB
Loading

src/content/posts/building-a-blog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: 'Building a blog with Astro and Sass'
33
pubDate: 2025-10-23
4+
cover: '../media/walking-in-woods.jpg'
5+
coverAlt: 'A photo of someone walking through woods, taken from a distance behind. There are bright green and yellow leaves.'
46
---
57

68
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non lorem diam. Quisque vulputate nibh sodales eros pretium tincidunt. Aenean porttitor efficitur convallis. Nulla sagittis finibus convallis. Phasellus in fermentum quam, eu egestas tortor. Maecenas ac mollis leo. Integer maximus eu nisl vel sagittis.
@@ -19,4 +21,6 @@ Eget at nec:
1921

2022
Etiam quis massa non massa sagittis accumsan eget at tellus. Quisque non fringilla magna, in tincidunt ligula. Nullam euismod, odio non luctus suscipit, neque quam mollis diam, in consequat augue mauris vitae nunc. Vestibulum consectetur quam ante. Donec vulputate dolor in odio ultricies, ut venenatis lorem luctus. Sed quis tellus risus. Nullam quis mi vitae nibh malesuada blandit. Duis sit amet tortor interdum, sodales est ut, pellentesque mi.
2123

24+
![An acoustic guitar leaning against a bed with a complex tiling pattern.](../media/acoustic-guitar.jpg)
25+
2226
Mauris non enim consectetur, ultrices lacus gravida, imperdiet lacus. Duis eget nulla nec turpis euismod laoreet. Nam tristique sem in elit lacinia tristique. Ut sem mi, suscipit quis nisi a, finibus ultrices eros. Donec sed ultricies est. Nullam volutpat metus sed dui lobortis tincidunt. Pellentesque rutrum maximus libero non luctus. Pellentesque id felis quis lacus varius tempus. Phasellus a est et justo mattis molestie a ac augue. Sed at purus erat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec dapibus eget nulla eu venenatis.

src/pages/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const posts = await getCollection("blog");
1010
<ul class="list-disc list-inside space-y-4">
1111
{posts.map((post) => (
1212
<li>
13-
<a href={`/posts/${post.id}/`} class="underline">
13+
<a href={`/posts/${post.id}/`}>
1414
{post.data.title} ({post.data.pubDate.toDateString()})
1515
</a>
1616
</li>

src/styles/_theme.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ $shadow-blur: 6px;
5656
$border-thickness: 1px;
5757
$border-radius: 2px;
5858

59+
$underline-thickness: 2px;
60+
5961
// Colors
6062

6163
$color-primary: #6d4c41;
6264
$color-primary-dark: #4c352d;
6365
$color-secondary: #3460bd;
66+
$color-subtle-light: #e2e2e2;
6467
$color-subtle: #c5c5c5;
6568
$color-subtle-dark:#7c7c7c;
6669
$color-neutral: #000000;

src/styles/global.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414

1515
h1, h2, h3, h4, h5, h6, p {
1616
padding-inline: $space-md;
17-
@include space-between($space-md);
18-
}
19-
20-
li {
21-
@include space-between($space-sm);
2217
}
2318

2419
h1, h2, h3, h4, h5, h6 {
@@ -30,5 +25,5 @@ a {
3025
font-weight: bold;
3126
color: $color-secondary;
3227
text-decoration: underline;
33-
text-decoration-thickness: 2px;
28+
text-decoration-thickness: $underline-thickness;
3429
}

src/styles/prose.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@use './_theme' as *;
2+
3+
.prose {
4+
line-height: $size-xl;
5+
6+
h1, h2, h3, h4, h5, h6, p {
7+
@include space-between($space-md);
8+
}
9+
10+
li {
11+
@include space-between($space-sm);
12+
}
13+
14+
img {
15+
display: block;
16+
border-radius: $border-radius;
17+
box-shadow: 0 $shadow-offset $shadow-blur $color-subtle;
18+
}
19+
}

0 commit comments

Comments
 (0)