From 4bced28e3e971ab04aef8ff1a3a7622e91ee2f86 Mon Sep 17 00:00:00 2001 From: Mihkel Martin Kasterpalu Date: Thu, 6 Feb 2025 01:36:54 +0200 Subject: [PATCH] Adjust types for Image.svelte --- src/lib/components/Image.svelte | 90 ++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/src/lib/components/Image.svelte b/src/lib/components/Image.svelte index 09c9c49..36c03f1 100644 --- a/src/lib/components/Image.svelte +++ b/src/lib/components/Image.svelte @@ -13,9 +13,9 @@ let { image, - tags = [], + tags, class: className - }: { image: EnhancedImage; tags: Tag[]; class: string } = $props(); + }: { image: EnhancedImage | undefined; tags?: Tag[]; class?: string } = $props(); let badgeVariant: BadgeVariant = $derived($mode == 'dark' ? 'secondary' : 'default'); @@ -36,52 +36,58 @@ {/snippet} -
- {#if typeof image.src === 'string'} - {image.alt} - {:else} - - {/if} - {#if tags} -
- {#each tags as { name, description }} - - - {name} - - - {description} - - - {/each} -
- {/if} +{#if image} +
+ {#if typeof image.src === 'string'} + {image.alt} + {:else} + + {/if} + {#if tags} +
+ {#each tags as { name, description }} + + + {name} + + + {description} + + + {/each} +
+ {/if} - {#if image.credit} -
-

- {#if image.credit.href} - + {#if image.credit} +

+

+ {#if image.credit.href} + + {@render creditText( + image.credit.author, + image.credit.type, + 'w-4 inline align-[-0.65em]' + )} + + {:else} {@render creditText( image.credit.author, image.credit.type, 'w-4 inline align-[-0.65em]' )} - - {:else} - {@render creditText(image.credit.author, image.credit.type, 'w-4 inline align-[-0.65em]')} - {/if} -

-
- {/if} -
+ {/if} +

+
+ {/if} +
+{/if}