~james/core

core/web/src/lib/components/profile/ProfileBio.svelte -rw-r--r-- 752 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<script lang="ts">
	import { resolve } from "$app/paths";
	import ProfilePopover from "#lib/components/profile/ProfilePopover.svelte";
	import { bioSegments } from "#lib/components/profile/bio.ts";

	interface Props {
		text: string;
		class?: string;
	}

	let { text, class: className }: Props = $props();

	const segments = $derived(bioSegments(text));
</script>

<div data-testid="profileBio" class={["whitespace-pre-line", className]}>
	{#each segments as segment, i (i)}
		{#if segment.kind === "mention"}
			<ProfilePopover identifier={segment.handle}>
				<a href={resolve(`/${segment.handle}` as "/")} class="font-medium hover:underline"
					>@{segment.handle}</a
				>
			</ProfilePopover>
		{:else}
			{segment.text}
		{/if}
	{/each}
</div>