your personal website on atproto - mirror blento.app
at profile-stuff 154 lines 4.5 kB view raw
1<script lang="ts"> 2 import { marked } from 'marked'; 3 import { user, login } from '$lib/atproto'; 4 import { Button } from '@foxui/core'; 5 import { BlueskyLogin } from '@foxui/social'; 6 import { env } from '$env/dynamic/public'; 7 import type { WebsiteData } from '$lib/types'; 8 import { getDescription, getImage, getName, getProfilePosition } from '$lib/helper'; 9 import { page } from '$app/state'; 10 import type { ActorIdentifier } from '@atcute/lexicons'; 11 import { qrOverlay } from '$lib/components/qr/qrOverlay.svelte'; 12 13 let { 14 data, 15 showEditButton = false 16 }: { 17 data: WebsiteData; 18 showEditButton?: boolean; 19 } = $props(); 20 21 const renderer = new marked.Renderer(); 22 renderer.link = ({ href, title, text }) => 23 `<a target="_blank" href="${href}" title="${title}">${text}</a>`; 24 25 const profileUrl = $derived(`${page.url.origin}/${data.handle}`); 26 const profilePosition = $derived(getProfilePosition(data)); 27</script> 28 29<!-- lg:fixed lg:h-screen lg:w-1/4 lg:max-w-none lg:px-12 lg:pt-24 xl:w-1/3 --> 30<div 31 class={[ 32 'mx-auto flex max-w-lg flex-col justify-between px-8', 33 profilePosition === 'side' 34 ? '@5xl/wrapper:fixed @5xl/wrapper:h-screen @5xl/wrapper:w-1/4 @5xl/wrapper:max-w-none @5xl/wrapper:px-12' 35 : '@5xl/wrapper:max-w-4xl @5xl/wrapper:px-12' 36 ]} 37> 38 <div 39 class={[ 40 'flex flex-col gap-4 pt-16 pb-8', 41 profilePosition === 'side' && '@5xl/wrapper:h-screen @5xl/wrapper:pt-24' 42 ]} 43 > 44 <a 45 href={profileUrl} 46 class="w-fit" 47 use:qrOverlay={{ 48 context: { 49 title: getName(data) + "'s blento" 50 } 51 }} 52 > 53 {#if data.publication?.icon || data.profile.avatar} 54 <img 55 class={[ 56 'border-base-400 dark:border-base-800 size-32 rounded-full border object-cover', 57 profilePosition === 'side' && '@5xl/wrapper:size-44' 58 ]} 59 src={getImage(data.publication, data.did, 'icon') || data.profile.avatar} 60 alt="" 61 /> 62 {:else} 63 <div 64 class={[ 65 'bg-base-300 dark:bg-base-700 size-32 rounded-full', 66 profilePosition === 'side' && '@5xl/wrapper:size-44' 67 ]} 68 ></div> 69 {/if} 70 </a> 71 72 <div class="text-4xl font-bold wrap-anywhere"> 73 {getName(data)} 74 </div> 75 76 <div class="scrollbar -mx-4 grow overflow-x-hidden overflow-y-scroll px-4"> 77 <div 78 class="text-base-600 dark:text-base-400 prose dark:prose-invert prose-a:text-accent-500 prose-a:no-underline" 79 > 80 {@html marked.parse(getDescription(data), { 81 renderer 82 })} 83 </div> 84 </div> 85 86 {#if showEditButton && user.isLoggedIn && user.profile?.did === data.did} 87 <div> 88 <Button href="{page.url}/edit" class="mt-2"> 89 <svg 90 xmlns="http://www.w3.org/2000/svg" 91 fill="none" 92 viewBox="0 0 24 24" 93 stroke-width="1.5" 94 stroke="currentColor" 95 > 96 <path 97 stroke-linecap="round" 98 stroke-linejoin="round" 99 d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" 100 /> 101 </svg> 102 103 Edit Your Website</Button 104 > 105 </div> 106 {:else} 107 <div class={['h-10.5 w-1', profilePosition === 'side' && '@5xl/wrapper:hidden']}></div> 108 {/if} 109 110 {#if !env.PUBLIC_IS_SELFHOSTED && data.handle === 'blento.app' && user.profile?.handle !== data.handle} 111 {#if !user.isInitializing && !user.isLoggedIn} 112 <div> 113 <div class="my-4 text-sm"> 114 To create your own blento, sign in with your bluesky account 115 </div> 116 <BlueskyLogin 117 login={async (handle) => { 118 await login(handle as ActorIdentifier); 119 return true; 120 }} 121 /> 122 </div> 123 {:else if user.isLoggedIn} 124 <div> 125 <Button href="/{env.PUBLIC_IS_SELFHOSTED ? '' : user.profile?.handle}/edit" class="mt-2"> 126 <svg 127 xmlns="http://www.w3.org/2000/svg" 128 fill="none" 129 viewBox="0 0 24 24" 130 stroke-width="1.5" 131 stroke="currentColor" 132 > 133 <path 134 stroke-linecap="round" 135 stroke-linejoin="round" 136 d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" 137 /> 138 </svg> 139 140 Edit Your Blento</Button 141 > 142 </div> 143 {/if} 144 {/if} 145 <div class={['hidden text-xs font-light', profilePosition === 'side' && '@5xl/wrapper:block']}> 146 made with <a 147 href="https://blento.app" 148 target="_blank" 149 class="hover:text-accent-600 dark:hover:text-accent-400 font-medium transition-colors duration-200" 150 >blento</a 151 > 152 </div> 153 </div> 154</div>