Skip to content

Commit 8734609

Browse files
committed
chore: localization button added
1 parent 165ffc9 commit 8734609

File tree

9 files changed

+145
-6
lines changed

9 files changed

+145
-6
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"eslint": "8.35.0",
1919
"eslint-config-next": "13.2.3",
2020
"framer-motion": "^11.0.3",
21+
"lodash": "^4.17.21",
2122
"negotiator": "^0.6.3",
2223
"next": "^14.2.3",
2324
"react": "^18.3.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use client'
2+
3+
import { themeCheck } from '@/utils/themeCheck'
4+
import { useParams, useRouter } from 'next/navigation'
5+
import { MouseEventHandler, useEffect, useState } from 'react'
6+
7+
const LocaleToggle = () => {
8+
const router = useRouter()
9+
const params = useParams()
10+
const locale = params.locale as string
11+
12+
const [iconToggle, setIconToggle] = useState<boolean>(themeCheck())
13+
14+
const handleLocaleSwitch: MouseEventHandler<HTMLButtonElement> = (e) => {
15+
e.preventDefault()
16+
router.replace(locale === 'ko' ? '/' : '/ko')
17+
setIconToggle(true)
18+
}
19+
20+
useEffect(() => {
21+
if (iconToggle === true) {
22+
setIconToggle(false)
23+
}
24+
}, [iconToggle])
25+
26+
console.log(locale === 'ko')
27+
28+
return (
29+
<button
30+
aria-label="Theme Toggle"
31+
onClick={handleLocaleSwitch}
32+
className="!text-light relative w-[36px] h-[36px] flex justify-center items-center rounded-full ring-1 ring-light/60 dark:bg-dark-80"
33+
>
34+
<span
35+
className={`absolute ${
36+
locale === 'en' || !locale ? 'rotate-0 opacity-100' : 'rotate-180 opacity-0'
37+
} transform transition duration-500 ease-in-out`}
38+
>
39+
<p className="text-sm font-semibold">EN</p>
40+
</span>
41+
<span
42+
className={`absolute ${
43+
locale === 'ko' ? 'rotate-0 opacity-100' : 'rotate-180 opacity-0'
44+
} transform transition duration-500 ease-in-out`}
45+
>
46+
<p className="text-sm font-semibold">KO</p>
47+
</span>
48+
</button>
49+
)
50+
}
51+
52+
export default LocaleToggle

src/app/[locale]/_components/MainContainer.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { ChatBubbleLeftEllipsisIcon, DocumentIcon } from '@heroicons/react/24/so
99
import { Application, SPEObject } from '@splinetool/runtime'
1010
import { motion } from 'framer-motion'
1111
import dynamic from 'next/dynamic'
12-
import { Inter } from 'next/font/google'
13-
import { useParams, usePathname, useSearchParams } from 'next/navigation'
12+
import { useParams } from 'next/navigation'
1413
import { useRef, useState } from 'react'
14+
import LocaleToggle from './LocaleToggle'
1515

1616
const Spline = dynamic(() => import('@splinetool/react-spline'), {
1717
ssr: false,
@@ -113,6 +113,9 @@ const MainContainer = () => {
113113
>
114114
<ChatBox isOpen={isBotChatOpened} />
115115
</div>
116+
<div className={`fixed w-full max-w-[1020px] flex justify-end z-30 pointer-events-auto top-4 end-4`}>
117+
<LocaleToggle />
118+
</div>
116119

117120
{navList.map((nav, i) => (
118121
<NavModal selected={selected === nav.name} {...nav} key={`nav-modal-${nav}-${i}`} />

src/app/[locale]/_components/NavModal.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ export const NavModal = ({ onClick, selected, ...nav }: Params) => {
4141
}
4242

4343
const windowWidth = useResizeHandler()
44+
4445
return isReady && document.getElementById(nav.name) ? (
4546
<motion.div
4647
key={`modal-${nav.name}-${windowWidth}`}
4748
initial={'closed'}
4849
animate={!!selected ? 'open' : 'closed'}
4950
variants={{
50-
open: (height = 1000) => ({
51+
open: (height = 500) => ({
5152
clipPath: `circle(${height * 2 + 200}px at ${
5253
(document.getElementById(nav.name)?.getBoundingClientRect().x as number) + 25
5354
}px ${(document.getElementById(nav.name)?.getBoundingClientRect().y as number) + 25}px)`,
@@ -83,7 +84,7 @@ export const NavModal = ({ onClick, selected, ...nav }: Params) => {
8384
<span className="w-[24px] h-[24px] aspect-square">{nav.icon}</span>
8485
</div>
8586
<Link
86-
href={!nav.external && nav.locale ? `/${nav.locale}${nav.href}` : nav.href}
87+
href={!nav.external ? `${nav.locale !== 'en' ? `/${nav.locale}` : ''}${nav.href}` : nav.href}
8788
target={nav.external ? '_blank' : undefined}
8889
className="text-light text-[36px] font-medium capitalize z-40 flex justify-center gap-4 items-center hover:underline pointer-events-auto"
8990
>

src/app/api/text-splitter/output.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
````ts
2+
[
3+
Document {
4+
pageContent: "# Henry's Blog (NoowaH)\n" +
5+
'\n' +
6+
"Welcome to the GitHub repository for my blog! This platform is a personal project where I share my development notes, studies, and showcase my portfolio. It's built with modern web technologies, focusing on performance, aesthetics, and interactivity.",
7+
metadata: { loc: [Object] }
8+
},
9+
Document {
10+
pageContent: '## Website Contents\n' +
11+
'\n' +
12+
"- **`/posts`**: This section contains my development notes and in-depth studies on various topics within software development. It's a space where I document my learning journey and share insights on complex concepts.\n" +
13+
'\n' +
14+
'- **`/about`**: Learn more about me, my background in software development, and what drives my passion for technology.',
15+
metadata: { loc: [Object] }
16+
},
17+
Document {
18+
pageContent: '- **`/about`**: Learn more about me, my background in software development, and what drives my passion for technology.\n' +
19+
'\n' +
20+
"- **`/works`**: A showcase of my portfolio, highlighting projects and works that I've contributed to or developed. This section demonstrates my skills and areas of expertise.",
21+
metadata: { loc: [Object] }
22+
},
23+
Document {
24+
pageContent: '## Stack\n' +
25+
'\n' +
26+
'The blog leverages a modern technology stack to deliver a seamless user experience:\n' +
27+
'\n' +
28+
'- **Next.js 14 (App Router)**: Utilizes the latest features of Next.js for efficient, scalable routing, enhancing the performance and SEO of the blog.\n' +
29+
'\n' +
30+
'- **TailwindCSS & PostCSS**: For styling, the blog uses TailwindCSS along with PostCSS for a utility-first CSS workflow, enabling responsive and customizable design with ease.',
31+
metadata: { loc: [Object] }
32+
},
33+
Document {
34+
pageContent: '- **TailwindCSS & PostCSS**: For styling, the blog uses TailwindCSS along with PostCSS for a utility-first CSS workflow, enabling responsive and customizable design with ease.\n' +
35+
'\n' +
36+
"- **Markdown**: Content for the blog posts is written in Markdown, allowing for easy formatting and maintenance of the blog's written content.\n" +
37+
'\n' +
38+
'- **Framer Motion**: This library is used to add smooth, powerful animations throughout the website, enriching the user interaction and visual appeal.',
39+
metadata: { loc: [Object] }
40+
},
41+
Document {
42+
pageContent: '- **Framer Motion**: This library is used to add smooth, powerful animations throughout the website, enriching the user interaction and visual appeal.\n' +
43+
'\n' +
44+
'- **SWR**: For data fetching, SWR is implemented to handle caching, revalidation, and fetching data, ensuring up-to-date content is served with minimal loading times.',
45+
metadata: { loc: [Object] }
46+
},
47+
Document {
48+
pageContent: '## Getting Started\n' +
49+
'\n' +
50+
'To set up the blog locally, follow these steps:\n' +
51+
'\n' +
52+
'1. Clone the repository:\n' +
53+
'\n' +
54+
'```bash\n' +
55+
'git clone https://github.com/henrynoowah/blog.git\n' +
56+
'cd blog\n' +
57+
'```',
58+
metadata: { loc: [Object] }
59+
}
60+
]
61+
````

src/app/api/text-splitter/route.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { promises as fs } from 'fs'
2+
import { MarkdownTextSplitter, RecursiveCharacterTextSplitter } from 'langchain/text_splitter'
3+
4+
export const GET = async () => {
5+
try {
6+
const text = await fs.readFile('README.md', 'utf-8')
7+
8+
const splitter = new RecursiveCharacterTextSplitter({
9+
chunkSize: 500,
10+
chunkOverlap: 50,
11+
separators: ['\n\n', '\n', ' ', '', '#', '##']
12+
})
13+
14+
const output = await splitter.createDocuments([text])
15+
return Response.json({ ...output })
16+
} catch (e) {
17+
console.log(e)
18+
}
19+
return new Response('Hello, Next.js!')
20+
}

src/components/common/layouts/header/Nav_mobile.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Nav_mobile = ({ navOption }: Params) => {
3636
}`}
3737
>
3838
<Link
39-
href={!nav.external && nav.locale ? `/${nav.locale}/${nav.href}` : nav.href}
39+
href={!nav.external ? `${nav.locale !== 'en' ? `/${nav.locale}` : ''}${nav.href}` : nav.href}
4040
target={nav.external ? '_blank' : undefined}
4141
>
4242
<Button className="w-full px-4 sm:px-10 flex justify-between items-center bg-transparent !text-light !text-md py-2 text-left">

src/components/common/themeToggle/ThemeToggle.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const ThemeToggle = () => {
2424

2525
return (
2626
<button
27+
type="button"
2728
aria-label="Theme Toggle"
2829
onClick={handleThemeSwitch}
2930
className="!text-light relative w-[36px] h-[36px] flex justify-center items-center rounded-full ring-1 ring-light dark:bg-dark-80"

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,7 @@ lodash.merge@^4.6.2:
22532253

22542254
lodash@^4.17.21:
22552255
version "4.17.21"
2256-
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
2256+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
22572257
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
22582258

22592259
longest-streak@^3.0.0:

0 commit comments

Comments
 (0)