Skip to content

Commit

Permalink
✨ feat(papago): add example
Browse files Browse the repository at this point in the history
  • Loading branch information
summerscar committed Dec 22, 2024
1 parent 304d880 commit 2b29af8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 38 deletions.
43 changes: 6 additions & 37 deletions app/actions/papago-translate-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function authorization(url: string, uuid: string) {

interface Meaning {
meaning: string;
examples: string[];
examples: Example[];
originalMeaning: string;
}

Expand All @@ -80,25 +80,14 @@ interface Po {
meanings: Meaning[];
}

interface Item {
entry: string;
subEntry?: string | null;
matchType: string;
hanjaEntry: string | null;
phoneticSigns: PhoneticSign[];
pos: Po[];
source: string;
url: string;
mUrl: string;
expDicTypeForm: string;
locale: string;
gdid: string;
expEntrySuperscript: string;
interface Example {
text: string;
translatedText: string;
}

interface Dict {
items?: Item[];
examples: string[];
examples: Example[];
isWordType: boolean;
}

Expand All @@ -107,17 +96,6 @@ interface PhoneticSign {
sign: string;
}

interface Meaning {
meaning: string;
examples: string[];
originalMeaning: string;
}

interface Po {
type: string;
meanings: Meaning[];
}

interface Item {
entry: string;
subEntry?: string | null;
Expand All @@ -136,15 +114,10 @@ interface Item {

interface TarDict {
items: Item[];
examples: string[];
examples: Example[];
isWordType: boolean;
}

interface TlitResult {
token: string;
phoneme: string;
}

interface Message {
tlitResult: TlitResult[];
}
Expand All @@ -158,10 +131,6 @@ interface TlitResult {
phoneme: string;
}

interface Message {
tlitResult: TlitResult[];
}

interface Tlit {
message: Message;
}
Expand Down
13 changes: 12 additions & 1 deletion app/components/papago-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ const PapagoResultRender = ({
{item.pos.map((posItem, posIndex) => (
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
<li key={posIndex} className="mb-1 last:mb-0 text-sm">
{posItem.type}
<span className="rounded-box bg-slate-200/40 px-2">
{posItem.type}
</span>
<ul>
{posItem.meanings.map((meaning, meaningIndex) => (
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
Expand All @@ -89,6 +91,15 @@ const PapagoResultRender = ({
__html: meaning.meaning,
}}
/>
{meaning.examples?.map((example) => (
<div key={example.text} className="pl-4 text-sm">
<p
// biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>
dangerouslySetInnerHTML={{ __html: example.text }}
/>
<p>{example.translatedText}</p>
</div>
))}
</li>
))}
</ul>
Expand Down

0 comments on commit 2b29af8

Please sign in to comment.