2023-03-11 01:36:30 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import type { Pronoun } from "$lib/api/entities";
|
|
|
|
|
|
|
|
export let pronouns: Pronoun;
|
|
|
|
|
|
|
|
let pronounText: string;
|
2023-03-21 15:06:55 +01:00
|
|
|
$: pronounText = updatePronouns(pronouns);
|
2023-03-14 01:33:11 +01:00
|
|
|
|
2023-03-21 15:06:55 +01:00
|
|
|
const updatePronouns = (pronouns: Pronoun) => {
|
|
|
|
if (pronouns.display_text) {
|
|
|
|
return pronouns.display_text;
|
|
|
|
} else {
|
|
|
|
const split = pronouns.pronouns.split("/");
|
|
|
|
if (split.length < 2) return split.join("/");
|
|
|
|
else return split.slice(0, 2).join("/");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let link: string;
|
|
|
|
let shouldLink: boolean;
|
|
|
|
|
|
|
|
$: link = pronouns.display_text
|
2023-03-14 02:18:21 +01:00
|
|
|
? `${pronouns.pronouns},${pronouns.display_text}`
|
|
|
|
: pronouns.pronouns;
|
2023-03-21 15:06:55 +01:00
|
|
|
$: shouldLink = pronouns.pronouns.split("/").length === 5;
|
2023-03-11 01:36:30 +01:00
|
|
|
</script>
|
|
|
|
|
2023-03-14 01:33:11 +01:00
|
|
|
{#if shouldLink}
|
2023-03-14 02:18:21 +01:00
|
|
|
<a href="/pronouns/{link}">{pronounText}</a>
|
2023-03-14 01:33:11 +01:00
|
|
|
{:else}
|
|
|
|
{pronounText}
|
|
|
|
{/if}
|