Navigation
Properties that control how navigation features are populated.
Stackbit provides multiple methods for viewing the structure of your site and the objects within it.
Content Editor
Navigation within the content editor will work once a content source is configured, but can be customized with the properties below.
treeViews
Controls the structure of the tree view in the content editor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
- The top-level
TreeViewNode
items must containchildren
or they will not be rendered in the tree.
Parameters
The function is passed a single options
object of type ConfigDelegate
, which contains the following properties:
getDefaultLocaleBySource
getDocumentById
getDocumentFieldForFieldPath
getDocuments
getLogger
getModelByName
getSchemas
These properties can be used to retrieve the models, documents, and field values necessary to build a tree with the site content.
Return Value
The return value should be an array of TreeViewNode
objects.
When the node in the tree represents a document, the shape of the object should be:
document
: ADocumentWithSource
object. If retrieving documents withoptions.getDocuments()
, supplying the individual documents here will suffice.label
(optional): Override the default label for the document, which is a title-like field.stableId
(optional): A unique ID for the document. This is unnecessary with typical usage.children
(optional): An array of nested tree view nodes.
When a node is a text-based grouping of other nodes, it supports the following properties:
label
: A string value, which will be the text shown on the screen.stableId
: A unique ID for the node.children
(optional): An array of nested tree view nodes.
The usage example above shows both of these node types.
Sitemap Navigator
The sitemap navigator gets populated either from the output of the siteMap
property or using the urlPath
property of every document from a page type model.
siteMap
Explicitly sets the list of pages listed in the sitemap navigator.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
- Type definitions are being explored and may change.
- Notice the following about the highlighted code above:
pageModels
makes use ofmodelExtensions
by automatically retrieving a set of model names whentype
is set topage
.- Documents without a
slug
are ignored because aurlPath
cannot be determined. getLocalizedFieldForLocale
is a utility that introspects an object and returns the appropriate field object. Within that object, avalue
property contains the value for the field.