Skip to content

Commit

Permalink
feat: adjust type childpage
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielduete committed Jun 18, 2024
1 parent dc53cc3 commit 97eb348
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/helpers/notionConverter/notionConverter.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ type ToggleBlock = BlockBase & {
}
}

type ChildPageBlock = BlockBase & {
export type ChildPageBlock = BlockBase & {
type: 'child_page'
child_page: {
child_page?: {
title: string
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/layout/components/NavBar/Desktop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PagesStoregedProvider,
usePagesStoraged,
} from '~/src/contexts/ContextPages'
import { ChildPageBlock } from '~/src/helpers/notionConverter/notionConverter.types'
import { SoundClickButton } from '~/src/utils/sounds'

import * as S from './styles'
Expand All @@ -25,11 +26,13 @@ const DesktopNavBar = () => {
router.push(`/contents/${idPage}`)
}

const paths = pages
?.map(page => {
const id = page.id
const title = page?.child_page?.title
const childPageBlocks = pages?.filter(
(block): block is ChildPageBlock => block.type === 'child_page'
)

const paths = childPageBlocks
?.map(({ id, child_page }) => {
const title = child_page?.title
return { id, title }
})
.filter(page => page.title !== undefined)
Expand Down

0 comments on commit 97eb348

Please sign in to comment.