From 97cce1d8fcc8cfce3a3c885f8832b687983b146a Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 14 Mar 2023 03:01:26 +0100 Subject: [PATCH] feat: add opengraph tags --- frontend/src/lib/api/entities.ts | 8 ++++ frontend/src/routes/+layout.svelte | 8 ++++ frontend/src/routes/+page.svelte | 7 +++ frontend/src/routes/@[username]/+page.svelte | 42 +++++++++++++++++- .../@[username]/[memberName]/+page.svelte | 44 ++++++++++++++++++- .../pronouns/[...pronouns]/+page.svelte | 10 +++++ 6 files changed, 117 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/api/entities.ts b/frontend/src/lib/api/entities.ts index 875cb10..66861dc 100644 --- a/frontend/src/lib/api/entities.ts +++ b/frontend/src/lib/api/entities.ts @@ -111,6 +111,14 @@ export enum ErrorCode { RequestTooBig = 4001, } +export const pronounDisplay = (entry: Pronoun) => { + if (entry.display_text) return entry.display_text; + + const split = entry.pronouns.split("/"); + if (split.length < 2) return split.join("/"); + else return split.slice(0, 2).join("/"); +}; + export const userAvatars = (user: User | MeUser | MemberPartialUser) => { if (!user.avatar) return []; diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index fccd7c6..99ff373 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -5,12 +5,20 @@ import Navigation from "./nav/Navigation.svelte"; import type { LayoutData } from "./$types"; import { version } from "$app/environment"; + import { PUBLIC_BASE_URL } from "$env/static/public"; export let data: LayoutData; const versionMismatch = data.git_commit !== version && data.git_commit !== "[unknown]"; + + pronouns.cc + + + + +
diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index f9c82a3..fd37ee8 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -1,5 +1,12 @@ + + pronouns.cc + + +

pronouns.cc

diff --git a/frontend/src/routes/@[username]/+page.svelte b/frontend/src/routes/@[username]/+page.svelte index f387b0a..05098ad 100644 --- a/frontend/src/routes/@[username]/+page.svelte +++ b/frontend/src/routes/@[username]/+page.svelte @@ -11,16 +11,56 @@ import PartialMemberCard from "$lib/components/PartialMemberCard.svelte"; import FallbackImage from "$lib/components/FallbackImage.svelte"; import { userStore } from "$lib/store"; - import { userAvatars } from "$lib/api/entities"; + import { pronounDisplay, userAvatars, WordStatus } from "$lib/api/entities"; + import { PUBLIC_BASE_URL } from "$env/static/public"; export let data: PageData; let bio: string | null; $: bio = data.bio ? sanitizeHtml(marked.parse(data.bio)) : null; + + const favNames = data.names.filter((entry) => entry.status === WordStatus.Favourite); + const favPronouns = data.pronouns.filter((entry) => entry.status === WordStatus.Favourite); @{data.name} - pronouns.cc + + + + + {#if data.avatar} + + {/if} + + {#if favNames.length !== 0 && favPronouns.length !== 0} + + {:else if favNames.length !== 0} + + {:else if favPronouns.length !== 0} + + {:else if data.bio && data.bio !== ""} + + {:else} + + {/if}
diff --git a/frontend/src/routes/@[username]/[memberName]/+page.svelte b/frontend/src/routes/@[username]/[memberName]/+page.svelte index 5c11172..2e4f35d 100644 --- a/frontend/src/routes/@[username]/[memberName]/+page.svelte +++ b/frontend/src/routes/@[username]/[memberName]/+page.svelte @@ -9,16 +9,58 @@ import PronounLink from "$lib/components/PronounLink.svelte"; import FallbackImage from "$lib/components/FallbackImage.svelte"; import { Button, Icon } from "sveltestrap"; - import { memberAvatars } from "$lib/api/entities"; + import { memberAvatars, pronounDisplay, WordStatus } from "$lib/api/entities"; + import { PUBLIC_BASE_URL } from "$env/static/public"; export let data: PageData; let bio: string | null; $: bio = data.bio ? sanitizeHtml(marked.parse(data.bio)) : null; + + const favNames = data.names.filter((entry) => entry.status === WordStatus.Favourite); + const favPronouns = data.pronouns.filter((entry) => entry.status === WordStatus.Favourite); {data.display_name ?? data.name} - @{data.user.name} - pronouns.cc + + + + + {#if data.avatar} + + {/if} + + {#if favNames.length !== 0 && favPronouns.length !== 0} + + {:else if favNames.length !== 0} + + {:else if favPronouns.length !== 0} + + {:else if data.bio && data.bio !== ""} + + {:else} + + {/if}
diff --git a/frontend/src/routes/pronouns/[...pronouns]/+page.svelte b/frontend/src/routes/pronouns/[...pronouns]/+page.svelte index 32e40f8..26d3e42 100644 --- a/frontend/src/routes/pronouns/[...pronouns]/+page.svelte +++ b/frontend/src/routes/pronouns/[...pronouns]/+page.svelte @@ -1,4 +1,5 @@ + + + + + +

{displayText}

Here are some example sentences using {displayText} pronouns!