Skip to content
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

Domain based routing #102

Merged
merged 3 commits into from
Dec 6, 2023
Merged

Domain based routing #102

merged 3 commits into from
Dec 6, 2023

Conversation

robisim74
Copy link
Owner

@robisim74 robisim74 commented Dec 5, 2023

#99

Localize path

export const config: SpeakConfig = {
  defaultLocale: { lang: 'en' },
  supportedLocales: [
    { domain: 'example.com', lang: 'en' },
    { domain: 'example.it', lang: 'it' },
    { withDomain: 'example.com', lang: 'de' }
  ],
  domainBasedRouting: {
    prefix: 'always'
  },
};

Prefix always

https://example.com/
https://example.com/page
https://example.it/it
https://example.it/it/page
https://example.com/de
https://example.com/de/page

Prefix as needed

https://example.com/
https://example.com/page
https://example.it
https://example.it/page
https://example.com/de
https://example.com/de/page

Translate path

export const rewriteRoutes: RewriteRouteOption[] = [
  // No prefix/paths for default locale
  {
    domain: 'example.com',
    paths: {}
  },
  {
    prefix: 'it',
    domain: 'example.it',
    paths: {
      'page': 'pagina'
    }
  },
  {
    prefix: 'de',
    withDomain: 'example.com',
    paths: {
      'page': 'seite'
    }
  }
];

Prefix always

https://example.com/
https://example.com/page
https://example.it/it
https://example.it/it/pagina
https://example.com/de
https://example.com/de/seite

Prefix as needed

https://example.com/
https://example.com/page
https://example.it
https://example.it/pagina
https://example.com/de
https://example.com/de/seite

Copy link

codesandbox bot commented Dec 5, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@robisim74 robisim74 merged commit f16a8e4 into main Dec 6, 2023
2 checks passed
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.

1 participant