-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve UX for adding links to profile.
- Loading branch information
Showing
7 changed files
with
104 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
src/lib/components/social-media/featured-social-media-button.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
<script> | ||
import { getFeaturedSocialMediaDetails } from '$lib/utils/social-links'; | ||
import { getFeaturedSocialMediaDetails, getSocialMediaDetails } from '$lib/utils/social-links'; | ||
import Icon from '@iconify/svelte'; | ||
export let url; | ||
const socialMedia = getSocialMediaDetails(url); | ||
const featuredSocialMedia = getFeaturedSocialMediaDetails(url); | ||
</script> | ||
|
||
{#if featuredSocialMedia} | ||
<a | ||
href={url} | ||
target="_blank" | ||
title={featuredSocialMedia.name} | ||
class="variant-outline-primary btn btn-icon-sm" | ||
> | ||
<span> | ||
<Icon icon={featuredSocialMedia.icon} class="h-6 w-6" /> | ||
</span> | ||
</a> | ||
{/if} | ||
<a | ||
href={url} | ||
target="_blank" | ||
title={featuredSocialMedia?.name || socialMedia.name} | ||
class="variant-outline-primary btn btn-icon-sm" | ||
> | ||
<span> | ||
<Icon icon={featuredSocialMedia?.icon || socialMedia.icon} class="h-6 w-6" /> | ||
</span> | ||
</a> |
23 changes: 10 additions & 13 deletions
23
src/lib/components/social-media/social-media-button.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
<script> | ||
import { getFeaturedSocialMediaDetails, getSocialMediaDetails } from '$lib/utils/social-links'; | ||
import { getSocialMediaDetails } from '$lib/utils/social-links'; | ||
import Icon from '@iconify/svelte'; | ||
export let label = ''; | ||
export let url; | ||
export let isEditing = false; | ||
const socialMedia = getSocialMediaDetails(url); | ||
const featuredSocialMedia = getFeaturedSocialMediaDetails(url); | ||
</script> | ||
|
||
{#if isEditing || !featuredSocialMedia} | ||
<a href={url} target="_blank" class="variant-filled btn"> | ||
{#if socialMedia?.icon} | ||
<span> | ||
<Icon icon={socialMedia.icon} class="h-6 w-6" /> | ||
</span> | ||
{/if} | ||
<a href={url} target="_blank" class="variant-filled btn"> | ||
{#if socialMedia?.icon} | ||
<span> | ||
<Icon icon={socialMedia.icon} class="h-6 w-6" /> | ||
</span> | ||
{/if} | ||
|
||
<span>{socialMedia?.name} </span> | ||
</a> | ||
{/if} | ||
<span>{label || socialMedia?.name} </span> | ||
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { error } from '@sveltejs/kit'; | ||
|
||
export async function GET(event) { | ||
const link = event.url.searchParams.get('url'); | ||
export async function GET({ url, fetch }) { | ||
const link = url.searchParams.get('url'); | ||
if (!link) error(400, { message: 'Link is missing' }); | ||
|
||
const url = new URL(link); | ||
|
||
const response = await fetch(url); | ||
const html = await response.text(); | ||
|
||
return new Response(JSON.stringify(html)); | ||
try { | ||
const resp = await fetch(link); | ||
console.log(resp); | ||
if (resp.ok) { | ||
const text = await resp.text(); | ||
return new Response(text); | ||
} | ||
return error(500, { message: 'Error fetching URL' }); | ||
} catch (e) { | ||
return error(500, { message: 'Error fetching URL' }); | ||
} | ||
} |