Skip to content

Commit

Permalink
feat(roadiz): add useRoadizBlock()
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelodelain committed Mar 3, 2024
1 parent aba2d63 commit ff02433
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions composables/use-roadiz-block.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { RoadizNodesSources, RoadizWalker } from '@roadiz/types'

export interface BlockProps {
walker: RoadizWalker
index: number
blocks?: RoadizWalker[]
numBlocks?: number | string
}

export function useBlock<T extends RoadizNodesSources>(blockProps: BlockProps) {
const walker = computed(() => blockProps.walker)
const item = computed<T>(() => walker.value.item as T)
const children = computed(() => walker.value.children)
const childrenItems = computed(() => children.value.map((walker) => walker.item))

return { item, children, childrenItems }
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"prettier": "^3.2.5"
},
"dependencies": {
"@roadiz/types": "^0.1.0",
"ufo": "^1.4.0"
},
"engines": {
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff02433

Please sign in to comment.