-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: do not generate index route on pix.fr to avoid conflicts
- Loading branch information
1 parent
410d0de
commit b96a3f1
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function filterNuxtPages(routes, config) { | ||
if (config.isPixSite && config.isFrenchDomain) { | ||
return routes.filter( | ||
(route) => !(route.name === 'index' && route.path === '/') | ||
) | ||
} | ||
|
||
return routes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { filterNuxtPages } from '~/services/filter-nuxt-pages' | ||
|
||
describe('FilterNuxtPages', () => { | ||
describe('when is french domain', () => { | ||
it('should return only locale home at root path', function () { | ||
// given | ||
const config = { | ||
isPixSite: true, | ||
isFrenchDomain: true, | ||
} | ||
const routes = [ | ||
{ name: 'locale_home___fr-fr', path: '/' }, | ||
{ name: 'index', path: '/' }, | ||
{ name: 'foo', path: '/foo' }, | ||
] | ||
|
||
// when | ||
const filteredRoutes = filterNuxtPages(routes, config) | ||
|
||
// then | ||
expect(filteredRoutes).toEqual([ | ||
{ name: 'locale_home___fr-fr', path: '/' }, | ||
{ name: 'foo', path: '/foo' }, | ||
]) | ||
}) | ||
}) | ||
|
||
describe('when is international domain', () => { | ||
it('should return routes as is', function () { | ||
// given | ||
const config = { | ||
isPixSite: true, | ||
isFrenchDomain: false, | ||
} | ||
const routes = [ | ||
{ name: 'locale_home___fr', path: '/fr/' }, | ||
{ name: 'index', path: '/' }, | ||
{ name: 'foo', path: '/foo' }, | ||
] | ||
|
||
// when | ||
const filteredRoutes = filterNuxtPages(routes, config) | ||
|
||
// then | ||
expect(filteredRoutes).toEqual([ | ||
{ name: 'locale_home___fr', path: '/fr/' }, | ||
{ name: 'index', path: '/' }, | ||
{ name: 'foo', path: '/foo' }, | ||
]) | ||
}) | ||
}) | ||
}) |