Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@next/bundle-analyzer": "16.1.1",
"@next/mdx": "16.1.1",
"codehike": "1.0.7",
"cookie": "^1.1.1",
"dayjs": "^1.11.19",
"jotai": "^2.16.0",
"lucide-react": "^0.562.0",
Expand Down
9 changes: 0 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/app/article/2024-10/check-target/tester.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const Tester: React.FC = () => {

return (
<div className="space-y-4">
<div className="rounded-large border border-transparent shadow-small dark:border-gray-600">
<div className="rounded-large shadow-small border border-transparent dark:border-gray-600">
<div className="flex items-center justify-between gap-4 px-4 pt-4">
<h3 className="font-medium">립스틱 배너 조건 설정 (AND)</h3>
<div className="flex gap-2">
Expand Down Expand Up @@ -171,7 +171,10 @@ export const Tester: React.FC = () => {
value={target.operator}
onChange={(value) => {
const newTargets = [...targets];
newTargets[index] = { ...target, operator: value };
newTargets[index] = {
...target,
operator: value,
};
setTargets(newTargets);
}}
/>{" "}
Expand Down Expand Up @@ -225,7 +228,7 @@ export const Tester: React.FC = () => {
<pre className="text-xs">{JSON.stringify(root, null, 2)}</pre>
</div>
<div>
<div className="mb-4 rounded-large border border-transparent shadow-small dark:border-gray-600">
<div className="rounded-large shadow-small mb-4 border border-transparent dark:border-gray-600">
<div className="px-4 pt-4">
<h3 className="font-medium">방문자</h3>
</div>
Expand Down
20 changes: 0 additions & 20 deletions src/app/set-locale/route.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/modules/article/ArticleHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function ArticleHeader({
if (available.length >= 2) {
languageLinks = available.map((l) => ({
locale: l,
href: `/set-locale?locale=${l}&to=/${l}/${slug}`,
href: `/${l}/${slug}`,
}));
}
} catch {
Expand Down
26 changes: 9 additions & 17 deletions src/modules/i18n/useLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,16 @@

import { i18n, type Locale } from "@/modules/i18n/types";
import { usePathname } from "next/navigation";
import { getLocaleFromPathname, isLocale } from "./util";
import * as cookie from "cookie";

function getLocaleFromCookie(): Locale | null {
if (typeof document === "undefined") {
return null;
}

const cookies = cookie.parse(document.cookie);
const localeRaw = cookies.locale || "";
return isLocale(localeRaw) ? localeRaw : null;
}
import { getLocaleFromPathname } from "./util";

/**
* URL pathname 기반으로 locale을 결정합니다.
* - /ko/... 또는 /en/... 경로: 해당 locale 사용
* - 그 외 모든 경로: 기본 locale(ko) 사용
*
* 쿠키 기반 locale은 사용하지 않습니다. (일관성 유지)
*/
export function useLocale(): Locale {
const pathname = usePathname();
const localeFromCooikie = getLocaleFromCookie();

return (
getLocaleFromPathname(pathname) || localeFromCooikie || i18n.defaultLocale
);
return getLocaleFromPathname(pathname) ?? i18n.defaultLocale;
}
1 change: 0 additions & 1 deletion src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default function proxy(req: NextRequest) {
pathname.startsWith("/_next") ||
pathname.match(/\.[^/]+$/) ||
seg1 === "api" ||
seg1 === "set-locale" ||
(i18n.locales as readonly string[]).includes(seg1)
) {
return NextResponse.next();
Expand Down