File tree Expand file tree Collapse file tree
web/sections/MagazineTags Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111import { Link } from '@/core/Link'
1212import { twMerge } from '@/lib/twMerge/twMerge'
1313import { TransformableIcon } from '../../icons/TransformableIcon'
14+ import { magazineSlug } from '@/sitesConfig'
1415
1516export 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+
2936const 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
You can’t perform that action at this time.
0 commit comments