Skip to content

fix: support language dynamic slug in OneNavigation #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

syi0808
Copy link

@syi0808 syi0808 commented Apr 29, 2025

Cause

The #228 issue was caused by one Navigation's link being fixed as a Korean link.
To fix this, I modified it so that It can put language dynamic plugs in the link.

📝 Key Changes

  • Add language dynamic slug in ONE_NAVIGATION_ITEMS
  • Create new navigationItems with dynamic slugs replaced

🖼️ Before and After Comparison

Before

issue.mov

After

2025-04-29.7.37.12.mov

Resolve #228

Copy link

vercel bot commented Apr 29, 2025

@syi0808 is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

@syi0808
Copy link
Author

syi0808 commented Apr 29, 2025

If we want to prevent human error with TypeScript out of necessity, we can do the following, but it seems to be too much for me personally.

type AllowedSlug = 'lang';

type ValidateDynamic<S extends string> =
  S extends `${infer _Start}{${infer Param}}${infer Rest}`
    ? Param extends AllowedSlug
      ? ValidateDynamic<Rest> extends never
        ? never
        : S
      : never
    : S;

export interface NavItem<H extends string = string> {
  path: string;
  href: ValidateDynamic<H>;
  tooltip: {
    ko: string;
    en: string;
  };
  icon: string;
}

function defineNavItem<H extends string>(
  item: Omit<NavItem<H>, 'href'> & { href: ValidateDynamic<H> }
) {
  return item as NavItem<H>;
}

const ONE_NAVIGATION_ITEMS: NavItem[] = [
  defineNavItem({
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: Language State Reverts to Korean after changing tabs
1 participant