useContentHelpers()

Usage

useContentHelpers() is available everywhere in your app and gives access to helpers to interact with the navigation object.

<script setup lang="ts">const {  navBottomLink,  navDirFromPath,  navPageFromPath,  navKeyFromPath} = useContentHelpers()</script>

This function will take a navigation node and will resolve the first available path from that node.

It can be useful to build nested navigations systems.

Example:

const { navigation } = useContent()const path = navBottomLink(navigation.value)

This function will take a path and will resolve the first available navigation node from that path.

It can be useful to find the current directory of a navigation node.

Example:

const route = useRoute()const { navigation } = useContent()const dir = navDirFromPath(route.path, navigation.value)

This function will take a path and will resolve the first available navigation page from that path.

It can be useful to find the current navigation node the page you're browsing.

Example:

const route = useRoute()const { navigation } = useContent()const page = navPageFromPath(route.path, navigation.value)

This function will take a path and will resolve a specific key from that path.

It can be useful when you want to add a fallback on the _dir.yml value of a key in a page.

Example:

const route = useRoute()const { navigation } = useContent()const layout = navKeyFromPath(route.path, 'layout', navigation.value)