From 3ccf6780108b222a64ccbce24b98edbecce2b0e2 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 24 Jul 2024 23:35:37 +0800 Subject: [PATCH] fixed shortener card on links page not showing correct url for shortener with custom project domain --- .../src/lib/components/ShortenerCard.svelte | 40 +++++++++++-------- .../src/routes/(app)/links/+page.server.ts | 2 + frontend/src/routes/(app)/links/+page.svelte | 4 +- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/frontend/src/lib/components/ShortenerCard.svelte b/frontend/src/lib/components/ShortenerCard.svelte index 76ff759..1e463c7 100644 --- a/frontend/src/lib/components/ShortenerCard.svelte +++ b/frontend/src/lib/components/ShortenerCard.svelte @@ -8,7 +8,7 @@ import { Badge } from '$lib/components/ui/badge' import { ScrollArea } from '$lib/components/ui/scroll-area' import { Separator } from '$lib/components/ui/separator' - import type { Shortener } from '$lib/db/types' + import type { Project, Shortener } from '$lib/db/types' import { BarChart, EditIcon, @@ -28,6 +28,7 @@ projectName: string | null projectUuid: string | null visitorCount: number + project: Project | null } export let shortener_url: string @@ -80,11 +81,15 @@ } const hostDomain = 'https://' + shortener.link.split('/')[2] + + const shortenerUrl = shortener.project?.enable_custom_domain + ? shortener.project.custom_domain || shortener_url + : shortener_url - + -
+
+ class="max-w-[250px] overflow-x-clip overflow-ellipsis whitespace-nowrap"> {shortener.link}
@@ -108,12 +113,12 @@
+ class="flex items-center gap-2 text-sm text-muted-foreground"> - {shortener_url + '/' + shortener.code} + {shortenerUrl + '/' + shortener.code}
@@ -129,13 +134,13 @@ href={`/links/${shortener.code}/edit`} on:click|preventDefault={() => showEditModal(shortener.code)}> - + Edit openDeleteDialog(shortener.code)} - class="flex gap-2 items-center text-destructive data-[highlighted]:bg-destructive"> + class="flex items-center gap-2 text-destructive data-[highlighted]:bg-destructive"> Delete @@ -145,11 +150,11 @@ -
+