Skip to content

Commit 69d677c

Browse files
committed
Fix magazine filter #3425
1 parent ff0415f commit 69d677c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

web/sections/MagazineTags/MagazineTagBar.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { Link } from '@/core/Link'
1212
import { twMerge } from '@/lib/twMerge/twMerge'
1313
import { TransformableIcon } from '../../icons/TransformableIcon'
14+
import { magazineSlug } from '@/sitesConfig'
1415

1516
export type TagLink = {
1617
id: string
@@ -26,11 +27,17 @@ export type MagazineTagBarProps = {
2627
className?: string
2728
}
2829

30+
const getPath = (pathname:string):string=>{
31+
const paths = pathname.split("/")
32+
const isIndexPage = paths[paths.length-1] === magazineSlug["en_GB"] || paths[paths.length-1] === magazineSlug["nb_NO"]
33+
return isIndexPage ? pathname : paths.slice(0, paths.length-1).join("/")
34+
}
35+
2936
const MagazineTagBar = forwardRef<HTMLDivElement, MagazineTagBarProps>(
3037
function MagazineTagBar({ tags = [], className = '' }, ref) {
3138
const pathname = usePathname()
3239
const searchParams = useSearchParams()
33-
const parentSlug = pathname || ''
40+
const parentSlug = getPath(pathname)|| ''
3441
const query = searchParams?.get('tag') ?? null
3542
const isAllActive = !query || query === 'all'
3643

0 commit comments

Comments
 (0)