Find Neighbours
Find the neighbours of a page from the page tree
Find the neighbours of a page from the page tree, it returns the next and previous page of a given page. It is useful for implementing a footer.
For example:
Quick Start | next: Installation |
Installation | previous: Quick Start, next: Concepts |
Concepts | previous: Installation |
Usage
It requires a page tree and the url of page.
import { getPageUrl } from 'next-docs-zeta/contentlayer'
import { findNeighbour } from 'next-docs-zeta/server'
const url = getPageUrl(params.slug.split('/'), '/docs')
const neighbours = findNeighbour(tree, url)
Parameter | Type | Description |
---|---|---|
tree | PageTree | The page tree |
url | string | The url of page |
Last updated on 8/18/2023