Skip to content

Commit

Permalink
updated pathname.match
Browse files Browse the repository at this point in the history
  • Loading branch information
okeino committed Jan 4, 2024
1 parent 8a92f5f commit 5ec3257
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
17 changes: 8 additions & 9 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ module.exports = withBundleAnalyzer(
},
{
source: '/:lang/audiobibles/books/ENGESV/:testamentCode/:bookCode/2',
destination: '/:lang/bibles',
destination: '/:lang/bibles/',
permanent: false,
},
{
source: '/:lang/audiobibles/volumes',
destination: '/:lang/bibles',
destination: '/:lang/bibles/',
permanent: true,
},
{
Expand All @@ -308,12 +308,12 @@ module.exports = withBundleAnalyzer(
},
{
source: '/:lang/audiobibles/books/ENGESV/2',
destination: '/:lang/bibles',
destination: '/:lang/bibles/',
permanent: false,
},
{
source: '/:lang/audiobibles/books/ENGESV/2',
destination: '/:lang/bibles',
destination: '/:lang/bibles/',
permanent: false,
},
{
Expand Down Expand Up @@ -345,11 +345,6 @@ module.exports = withBundleAnalyzer(
permanent: false,
destination: '/:lang/stories/albums/page/1',
},
{
source: '/:lang/bibles/:path*',
destination: '/:lang/biles/:path*',
permanent: true,
},
{
source: '/:lang/audiobooks/books/:path*',
destination: '/:lang/books/:path*',
Expand Down Expand Up @@ -533,6 +528,10 @@ module.exports = withBundleAnalyzer(
source: '/:lang/blog',
destination: '/:lang/blog/page/1',
},
{
source: '/:lang/bibles',
destination: '/:lang/bibles/',
},
{
source: '/:lang/books',
destination: '/:lang/books/page/1',
Expand Down
8 changes: 5 additions & 3 deletions src/components/organisms/searchResults.filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ export type EntityFilterId = keyof typeof filters;
export function useContextualFilterId(): EntityFilterId {
const { pathname } = useRouter();
const filterIds = Object.keys(filters) as EntityFilterId[];
const filterId = filterIds.find((id) =>
pathname.match(`/\\[language\\]\\/${id}/`)
);
const filterId = filterIds.find((id) => {
if (pathname.match(`/\\[language\\]\\/${id}/`))
return pathname.match(`/\\[language\\]\\/${id}/`);
else return pathname.match(`/\\[language\\]\\/${id}`);
});

return filterId || 'all';
}
Expand Down

0 comments on commit 5ec3257

Please sign in to comment.