2023-03-11 16:52:48 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import { marked } from "marked";
|
|
|
|
import sanitizeHtml from "sanitize-html";
|
|
|
|
|
|
|
|
import FieldCard from "$lib/components/FieldCard.svelte";
|
|
|
|
|
|
|
|
import type { PageData } from "./$types";
|
|
|
|
import StatusIcon from "$lib/components/StatusIcon.svelte";
|
|
|
|
import PronounLink from "$lib/components/PronounLink.svelte";
|
|
|
|
import FallbackImage from "$lib/components/FallbackImage.svelte";
|
2023-03-14 17:06:35 +01:00
|
|
|
import { Alert, Button, Icon } from "sveltestrap";
|
2023-03-14 03:01:26 +01:00
|
|
|
import { memberAvatars, pronounDisplay, WordStatus } from "$lib/api/entities";
|
|
|
|
import { PUBLIC_BASE_URL } from "$env/static/public";
|
2023-03-14 17:06:35 +01:00
|
|
|
import { userStore } from "$lib/store";
|
2023-03-11 16:52:48 +01:00
|
|
|
|
|
|
|
export let data: PageData;
|
|
|
|
|
|
|
|
let bio: string | null;
|
2023-03-14 22:35:40 +01:00
|
|
|
$: bio = data.bio ? sanitizeHtml(marked.parse(data.bio, { breaks: true })) : null;
|
2023-03-14 03:01:26 +01:00
|
|
|
|
|
|
|
const favNames = data.names.filter((entry) => entry.status === WordStatus.Favourite);
|
|
|
|
const favPronouns = data.pronouns.filter((entry) => entry.status === WordStatus.Favourite);
|
2023-03-11 16:52:48 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="container">
|
2023-03-14 17:06:35 +01:00
|
|
|
{#if $userStore && $userStore.id === data.user.id}
|
|
|
|
<Alert color="secondary" fade={false}>
|
2023-03-14 17:16:11 +01:00
|
|
|
You are currently viewing the <strong>public</strong> profile of {data.display_name ??
|
|
|
|
data.name}.
|
2023-03-14 17:06:35 +01:00
|
|
|
<br /><a href="/edit/member/{data.id}">Edit profile</a>
|
|
|
|
</Alert>
|
|
|
|
{/if}
|
2023-03-14 22:31:45 +01:00
|
|
|
<div class="m-3">
|
2023-03-11 16:52:48 +01:00
|
|
|
<Button color="secondary" href="/@{data.user.name}">
|
|
|
|
<Icon name="arrow-left" /> Back to {data.user.display_name ?? data.user.name}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
<div class="grid">
|
|
|
|
<div class="row">
|
2023-03-14 17:19:10 +01:00
|
|
|
<div class="col-md-4 text-center">
|
2023-03-13 02:04:09 +01:00
|
|
|
<FallbackImage width={200} urls={memberAvatars(data)} alt="Avatar for @{data.name}" />
|
2023-03-11 16:52:48 +01:00
|
|
|
</div>
|
2023-03-12 15:59:20 +01:00
|
|
|
<div class="col-md">
|
2023-03-11 16:52:48 +01:00
|
|
|
<h2>{data.display_name ?? data.name}</h2>
|
|
|
|
<h5 class="text-body-secondary">{data.name} (@{data.user.name})</h5>
|
|
|
|
{#if bio}
|
2023-03-12 15:59:20 +01:00
|
|
|
<hr />
|
2023-03-11 16:52:48 +01:00
|
|
|
<p>{@html bio}</p>
|
|
|
|
{/if}
|
2023-03-12 15:59:20 +01:00
|
|
|
</div>
|
|
|
|
{#if data.links.length > 0}
|
|
|
|
<div class="col-md d-flex align-items-center">
|
2023-03-12 05:04:15 +01:00
|
|
|
<ul class="list-unstyled">
|
2023-03-11 16:52:48 +01:00
|
|
|
{#each data.links as link}
|
2023-03-12 05:04:15 +01:00
|
|
|
<li><Icon name="globe" /> <a href={link}>{link}</a></li>
|
2023-03-11 16:52:48 +01:00
|
|
|
{/each}
|
|
|
|
</ul>
|
2023-03-12 15:59:20 +01:00
|
|
|
</div>
|
|
|
|
{/if}
|
2023-03-11 16:52:48 +01:00
|
|
|
</div>
|
2023-03-12 04:25:53 +01:00
|
|
|
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3">
|
2023-03-12 05:04:15 +01:00
|
|
|
{#if data.names.length > 0}
|
2023-03-11 16:52:48 +01:00
|
|
|
<div class="col-md">
|
2023-03-14 14:27:54 +01:00
|
|
|
<h3>Names</h3>
|
|
|
|
<ul class="list-unstyled fs-5">
|
2023-03-11 16:52:48 +01:00
|
|
|
{#each data.names as name}
|
|
|
|
<li><StatusIcon status={name.status} /> {name.value}</li>
|
|
|
|
{/each}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2023-03-12 05:04:15 +01:00
|
|
|
{#if data.pronouns.length > 0}
|
2023-03-11 16:52:48 +01:00
|
|
|
<div class="col-md">
|
2023-03-14 14:27:54 +01:00
|
|
|
<h3>Pronouns</h3>
|
|
|
|
<ul class="list-unstyled fs-5">
|
2023-03-11 16:52:48 +01:00
|
|
|
{#each data.pronouns as pronouns}
|
|
|
|
<li>
|
|
|
|
<StatusIcon status={pronouns.status} />
|
|
|
|
<PronounLink {pronouns} />
|
|
|
|
</li>
|
|
|
|
{/each}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{#each data.fields as field}
|
|
|
|
<div class="col">
|
|
|
|
<FieldCard {field} />
|
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</div>
|
2023-03-12 04:25:53 +01:00
|
|
|
</div>
|
2023-03-11 16:52:48 +01:00
|
|
|
</div>
|
2023-03-14 14:27:54 +01:00
|
|
|
|
|
|
|
<svelte:head>
|
|
|
|
<title>{data.display_name ?? data.name} - @{data.user.name} - pronouns.cc</title>
|
|
|
|
|
|
|
|
<meta
|
|
|
|
property="og:title"
|
|
|
|
content={data.display_name
|
|
|
|
? `${data.display_name} (${data.name})`
|
|
|
|
: `${data.name} (@${data.user.name})`}
|
|
|
|
/>
|
|
|
|
<meta property="og:url" content="{PUBLIC_BASE_URL}/@{data.user.name}/{data.name}" />
|
|
|
|
|
|
|
|
{#if data.avatar}
|
|
|
|
<meta property="og:image" content={memberAvatars(data)[0]} />
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if favNames.length !== 0 && favPronouns.length !== 0}
|
|
|
|
<meta
|
|
|
|
property="og:description"
|
2023-03-14 22:26:21 +01:00
|
|
|
content="{data.display_name ?? data.name} goes by {favNames
|
|
|
|
.map((x) => x.value)
|
|
|
|
.join(', ')} and uses {favPronouns.map((x) => pronounDisplay(x)).join(', ')} pronouns."
|
2023-03-14 14:27:54 +01:00
|
|
|
/>
|
|
|
|
{:else if favNames.length !== 0}
|
|
|
|
<meta
|
|
|
|
property="og:description"
|
2023-03-14 22:26:21 +01:00
|
|
|
content="{data.display_name ?? data.name} goes by {favNames.map((x) => x.value).join(', ')}."
|
2023-03-14 14:27:54 +01:00
|
|
|
/>
|
|
|
|
{:else if favPronouns.length !== 0}
|
|
|
|
<meta
|
|
|
|
property="og:description"
|
2023-03-14 22:26:21 +01:00
|
|
|
content="{data.display_name ?? data.name} uses {favPronouns
|
|
|
|
.map((x) => pronounDisplay(x))
|
|
|
|
.join(', ')} pronouns."
|
2023-03-14 14:27:54 +01:00
|
|
|
/>
|
|
|
|
{:else if data.bio && data.bio !== ""}
|
|
|
|
<meta
|
|
|
|
property="og:description"
|
2023-03-14 22:26:21 +01:00
|
|
|
content="{data.bio.slice(0, 500)}{data.bio.length > 500 ? '…' : ''}"
|
2023-03-14 14:27:54 +01:00
|
|
|
/>
|
|
|
|
{:else}
|
|
|
|
<meta property="og:description" content="{data.name} (@{data.user.name}) on pronouns.cc" />
|
|
|
|
{/if}
|
|
|
|
</svelte:head>
|