image uses caption
This commit is contained in:
parent
acc5bbd363
commit
b338fced35
2 changed files with 18 additions and 1 deletions
16
src/lib/components/Image.svelte
Normal file
16
src/lib/components/Image.svelte
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<script lang="ts">
|
||||||
|
interface Props {
|
||||||
|
src: string;
|
||||||
|
alt: string;
|
||||||
|
caption?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { src, alt, caption }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<figure class="flex flex-col">
|
||||||
|
<img class="aspect-4/2 w-full object-cover" {src} {alt} />
|
||||||
|
{#if caption}
|
||||||
|
<figcaption class="mt-2 text-center text-sm text-gray-500 italic">{caption}</figcaption>
|
||||||
|
{/if}
|
||||||
|
</figure>
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
import SvelteMarkdown from '@humanspeak/svelte-markdown';
|
import SvelteMarkdown from '@humanspeak/svelte-markdown';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import type { PageProps } from './$types';
|
import type { PageProps } from './$types';
|
||||||
|
import Image from '$lib/components/Image.svelte';
|
||||||
|
|
||||||
let { data }: PageProps = $props();
|
let { data }: PageProps = $props();
|
||||||
|
|
||||||
|
|
@ -21,7 +22,7 @@
|
||||||
<p class="text-gray-500">{dayjs(post.published).format('DD MMMM YYYY')}</p>
|
<p class="text-gray-500">{dayjs(post.published).format('DD MMMM YYYY')}</p>
|
||||||
<h1 class="text-4xl font-light">{post.title}</h1>
|
<h1 class="text-4xl font-light">{post.title}</h1>
|
||||||
</div>
|
</div>
|
||||||
<img class="aspect-4/2 w-full object-cover" src={post.image.url} alt={post.image.alt} />
|
<Image src={post.image.url} alt={post.image.alt} caption={post.image.caption} />
|
||||||
<div class="w-full max-w-5xl px-4">
|
<div class="w-full max-w-5xl px-4">
|
||||||
<SvelteMarkdown
|
<SvelteMarkdown
|
||||||
source={data.post.body}
|
source={data.post.body}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue