Skip to content

Commit

Permalink
More style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPower committed Dec 19, 2024
1 parent f906058 commit 3a446fd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
25 changes: 0 additions & 25 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,11 @@ h1 {
font-weight: 600;
}

h1:not(:first-child) {
margin-top: 1.25rem;
}

h2 {
font-size: 1.2rem;
font-weight: 600;
}

h2:not(:first-child) {
margin-top: 1rem;
}

h3 {
font-size: 1.1rem;
font-weight: 500;
Expand All @@ -77,23 +69,6 @@ p:not(:first-child) {
margin-top: 0.75rem;
}

figure {
max-width: 40rem;
margin-top: 1rem;
}

img {
display: block;
max-width: 100%;
}

figcaption {
font-size: 0.8em;
background-color: var(--color-dark);
padding: 0.25rem;
color: var(--color-fg);
}

pre[class*="language-"] {
font-size: 0.75rem;
background-color: var(--color-dark);
Expand Down
18 changes: 18 additions & 0 deletions src/lib/components/Image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@
<figcaption><slot /></figcaption>
{/if}
</figure>

<style>
img {
display: block;
max-width: 100%;
}
figure {
max-width: 40rem;
}
figcaption {
font-size: 0.8em;
background-color: var(--color-dark);
padding: 0.25rem;
color: var(--color-fg);
}
</style>
3 changes: 2 additions & 1 deletion src/lib/server/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ const data = await Promise.all(

const posts = data
.map(({ default: component, metadata }, index) => {
const { body } = render(component);
const { body, head } = render(component);
return {
title: metadata.title,
draft: !metadata.date,
date: metadata.date || new Date().toISOString().slice(0, 10),
slug: slugs[index],
body,
head,
};
})
.sort((a, b) => +new Date(b.date) - +new Date(a.date))
Expand Down
17 changes: 16 additions & 1 deletion src/routes/blog/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
export let data;
</script>

<svelte:head>
{@html data.head}
</svelte:head>
<div class="post-heading">
<h1>{data.title}</h1>
<div>
<p>Published on: {data.date}</p>
</div>
</div>
{@html data.body}
<div class="post-body">
{@html data.body}
</div>

<style>
.post-heading {
Expand All @@ -17,4 +22,14 @@
align-items: center;
margin: 0 auto;
}
.post-body :global(h2) {
margin-top: 1.5rem;
}
.post-body :global(h3) {
margin-top: 1rem;
}
.post-body :global(figure) {
margin-top: 1rem;
}
</style>

0 comments on commit 3a446fd

Please sign in to comment.