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

Merged
merged 1 commit into from
Jun 9, 2025

Conversation

syi0808
Copy link
Contributor

@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
Contributor 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({
    ...

@milooy
Copy link
Collaborator

milooy commented May 16, 2025

Thank you 👍
Can you rebase with latest main branch and check again?
Bundling Fundamental documentation is merged in only Korean.

It'll be great if we can link like this

  • (Ko) One nav > Bundling Fundamentals > Real Documentation
  • (!Ko) One nav > Bundling Fundamentals > Coming soon / Translation needed (in eng)

@syi0808 syi0808 force-pushed the fix/keep-lang-when-switch-tabs branch 5 times, most recently from bac718c to 6a3f453 Compare May 17, 2025 13:59
@syi0808 syi0808 force-pushed the fix/keep-lang-when-switch-tabs branch from 6a3f453 to c3e6d19 Compare May 17, 2025 13:59
@syi0808
Copy link
Contributor Author

syi0808 commented May 17, 2025

@milooy I implemented the action you suggested as follows.

  1. Set the bundling project to support other languages, and temporarily take action on index.md as the coming-soon page.
  2. Add {lang} to the href property of the new one navigation items.

Copy link
Collaborator

@milooy milooy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@milooy milooy merged commit eb7f928 into toss:main Jun 9, 2025
1 check failed
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
2 participants