Skip to content

Commit

Permalink
fix: fil arianne (#382)
Browse files Browse the repository at this point in the history
* fix: fil arianne

* fix: review seo

* fix: review BlockRenderer

---------

Co-authored-by: PassCulture <passculture@macstudelaurent.home>
  • Loading branch information
lheneman-pass and PassCulture committed Jun 21, 2024
1 parent 84b0d6d commit 208e427
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
25 changes: 19 additions & 6 deletions public_website/src/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,34 @@ import styled from 'styled-components'
import { BlockRenderer } from '@/lib/BlockRenderer'
import { Seo } from '@/lib/seo/seo'
import { APIResponseData } from '@/types/strapi'
import { Breadcrumb } from '@/ui/components/breadcrumb/Breadcrumb'
import { fetchCMS } from '@/utils/fetchCMS'

interface CustomPageProps {
data: APIResponseData<'api::page.page'>
}

export default function CustomPage(props: CustomPageProps) {
const { seo, Blocks } = props.data.attributes

return (
<PageWrapper>
{props.data.attributes.seo && (
<Seo metaData={props.data.attributes.seo} />
)}
{props.data.attributes.Blocks?.map((block) => (
<BlockRenderer key={`${block.__component}_${block.id}`} block={block} />
))}
{seo && <Seo metaData={seo} />}
{Blocks?.map((block, index) => {
const blockContent = (
<BlockRenderer
key={`${block.__component}_${block.id}`}
block={block}
/>
)
return index === 1 ? (
<React.Fragment key={`${block.__component}_${block.id}`}>
<Breadcrumb isUnderHeader /> {blockContent}
</React.Fragment>
) : (
blockContent
)
})}
</PageWrapper>
)
}
Expand Down
21 changes: 12 additions & 9 deletions public_website/src/ui/components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styled, { css } from 'styled-components'
import { ContentWrapper } from '../ContentWrapper'
import { ChevronDown } from '../icons/ChevronDown'
import { BreadcrumbContext } from './breadcrumb-context'
import { isStringAreEquals } from '@/utils/stringAreEquals'

interface BreadcrumbProps {
isUnderHeader?: boolean
Expand All @@ -21,13 +22,15 @@ export function Breadcrumb(props: BreadcrumbProps) {
return null
}

const currentNavigationGroup = headerData?.targetItems.find(
const allItems = [...headerData.targetItems, ...headerData.aboutItems]

const currentNavigationGroup = allItems.find(
(x) =>
x.megaMenu.primaryListItems.some(
(y) => y.URL.toLowerCase() === pathname.toLowerCase()
x.megaMenu.primaryListItems.some((y) =>
isStringAreEquals(y.URL, pathname)
) ||
x.megaMenu.secondaryListItems.some(
(y) => y.URL.toLowerCase() === pathname.toLowerCase()
x.megaMenu.secondaryListItems.some((y) =>
isStringAreEquals(y.URL, pathname)
)
)

Expand All @@ -40,11 +43,11 @@ export function Breadcrumb(props: BreadcrumbProps) {
...currentNavigationGroup.megaMenu.secondaryListItems,
]

const currentLink = groupLinks.find(
(l) => l.URL.toLowerCase() === pathname.toLowerCase()
)
const currentLink = groupLinks.find((y) => isStringAreEquals(y.URL, pathname))

const handleOptionChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
const handleOptionChange = (
event: React.ChangeEvent<HTMLSelectElement>
): void => {
let selectedUrl = event.target.value
selectedUrl = selectedUrl.startsWith('/') ? selectedUrl : '/' + selectedUrl
router.push(selectedUrl)
Expand Down

0 comments on commit 208e427

Please sign in to comment.