feat: add pronouns page
This commit is contained in:
parent
5ee069a5bd
commit
8cab186ee4
4 changed files with 82 additions and 1 deletions
24
frontend/src/routes/pronouns/[...pronouns]/+page.svelte
Normal file
24
frontend/src/routes/pronouns/[...pronouns]/+page.svelte
Normal file
|
@ -0,0 +1,24 @@
|
|||
<script lang="ts">
|
||||
import type { PageData } from "../../$types";
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const { subjective, objective, possessiveDeterminer, possessivePronoun, reflexive } = data;
|
||||
|
||||
const displayText = data.displayText || `${subjective}/${objective}`;
|
||||
</script>
|
||||
|
||||
<h1>{displayText}</h1>
|
||||
|
||||
<p>Here are some example sentences using <b>{displayText}</b> pronouns!</p>
|
||||
|
||||
<blockquote class="blockquote">
|
||||
<p><b class="text-capitalize">{subjective}</b> went to the park.</p>
|
||||
<p>I went with <b>{objective}</b>.</p>
|
||||
<p><b class="text-capitalize">{subjective}</b> brought <b>{possessiveDeterminer}</b> frisbee.</p>
|
||||
<p>At least, I think it was <b>{possessivePronoun}</b>.</p>
|
||||
<p>
|
||||
<b class="text-capitalize">{objective}</b> threw the frisbee to
|
||||
<b>{reflexive}</b>.
|
||||
</p>
|
||||
</blockquote>
|
42
frontend/src/routes/pronouns/[...pronouns]/+page.ts
Normal file
42
frontend/src/routes/pronouns/[...pronouns]/+page.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import { error } from "@sveltejs/kit";
|
||||
import type { PageLoad } from "./$types";
|
||||
|
||||
interface Pronouns {
|
||||
[key: string]: { pronouns: string[]; display?: string };
|
||||
}
|
||||
|
||||
export const load = (async ({ params }) => {
|
||||
const [param, displayText] = params.pronouns.split(",");
|
||||
|
||||
const arr = param.split("/");
|
||||
if (arr.length === 0 || params.pronouns === "") {
|
||||
throw error(404, "Pronouns not found");
|
||||
}
|
||||
|
||||
if (arr.length === 5) {
|
||||
return {
|
||||
displayText,
|
||||
subjective: arr[0],
|
||||
objective: arr[1],
|
||||
possessiveDeterminer: arr[2],
|
||||
possessivePronoun: arr[3],
|
||||
reflexive: arr[4],
|
||||
};
|
||||
}
|
||||
|
||||
const pronouns: Pronouns = (await import("$lib/pronouns.json")).pronouns;
|
||||
|
||||
if (params.pronouns in pronouns) {
|
||||
const entry = pronouns[params.pronouns];
|
||||
return {
|
||||
displayText: entry.display || "",
|
||||
subjective: entry.pronouns[0],
|
||||
objective: entry.pronouns[1],
|
||||
possessiveDeterminer: entry.pronouns[2],
|
||||
possessivePronoun: entry.pronouns[3],
|
||||
reflexive: entry.pronouns[4],
|
||||
};
|
||||
}
|
||||
|
||||
throw error(404, "Pronouns not found");
|
||||
}) satisfies PageLoad;
|
Loading…
Add table
Add a link
Reference in a new issue