diff --git a/src/app/api/ipa/route.ts b/src/app/api/ipa/route.ts new file mode 100644 index 0000000..5bb1668 --- /dev/null +++ b/src/app/api/ipa/route.ts @@ -0,0 +1,14 @@ +import { getIPA } from "@/utils"; +import { NextRequest, NextResponse } from "next/server"; + +export async function GET(request: NextRequest) { + const searchParams = request.nextUrl.searchParams; + + const text = searchParams.get('text'); + if (!text) return NextResponse.json({ 'error': 400 }, { status: 400 }); + + const r = await getIPA(text); + if (r === null) return NextResponse.json({ 'error': 424 }, { status: 424 }); + + return NextResponse.json({ r }, { status: 200 }); +} diff --git a/src/app/api/route.ts b/src/app/api/route.ts new file mode 100644 index 0000000..352f57f --- /dev/null +++ b/src/app/api/route.ts @@ -0,0 +1,9 @@ +import { NextRequest, NextResponse } from "next/server"; + +export async function GET(request: NextRequest) { + const url = request.url; + return NextResponse.json({ + message: "Hello World", + url: url + }, { status: 200 }); +} diff --git a/src/app/ipa-reader/layout.tsx b/src/app/ipa-reader/layout.tsx new file mode 100644 index 0000000..65594bd --- /dev/null +++ b/src/app/ipa-reader/layout.tsx @@ -0,0 +1,33 @@ +import type { Metadata } from "next"; +import { Geist, Geist_Mono } from "next/font/google"; + +const geistSans = Geist({ + variable: "--font-geist-sans", + subsets: ["latin"], +}); + +const geistMono = Geist_Mono({ + variable: "--font-geist-mono", + subsets: ["latin"], +}); + +export const metadata: Metadata = { + title: "IPA Reader", + description: "read ipa aloud", +}; + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return ( + +
+ {children} + + + ); +} diff --git a/src/app/ipa-reader/page.tsx b/src/app/ipa-reader/page.tsx new file mode 100644 index 0000000..a95ded8 --- /dev/null +++ b/src/app/ipa-reader/page.tsx @@ -0,0 +1,46 @@ +"use client"; + +import Button from "@/components/Button"; +import { getIPA, urlGoto } from "@/utils"; +import { useRef, useState } from "react"; + +export default function Home() { + const respref = useRef