Skip to main content
ESC

Items

Each item consists of the following keys:

Manual Generation 

Firstly, Robindoc reads the structure passed as an argument:

/docs/robindoc.ts
export const { Page, Sidebar } = initializeRobindoc({
// ...
items: [
{
title: "Introduction",
type: "heading",
href: "/",
configuration: {
sourceRoot: "..",
},
},
// ...
{
title: "Structure",
type: "heading",
href: "/02-structure",
items: [
// ...
{
title: "Data Source",
href: "/02-structure/03-data-source",
},
],
},
{
title: "Elements",
type: "heading",
href: "/01-elements",
items: "auto",
},
],
});

You can also pass an asynchronous callback as an argument. In this case, you can form the structure in a way that suits you.

/docs/robindoc.ts
export const { Page, Sidebar } = initializeRobindoc(async () => {
const items = await loadItems();

return {
configuration: {
sourceRoot: "../docs",
basePath: "/docs",
gitToken: "YOUR_TOKEN",
},
items,
};
});

This configuration determines the list of available and generated pages, all links, the sidebar tree, etc.

Automatic Generation 

To have the subtree generated automatically, you need to pass items: 'auto'.

/docs/robindoc.ts
export const { Page, Sidebar } = initializeRobindoc({
// ...
items: "auto",
});

You can add extra elements from third-party sources to automatically generated elements - items: [YOUR_OPTIONS, 'auto']

/docs/robindoc.ts
import { initializeRobindoc } from "robindoc";

export const { Page, Sidebar } = initializeRobindoc({
configuration: {
sourceRoot: "../docs",
basePath: "/docs",
},
items: [
{
title: "Introduction",
type: "heading",
href: "/",
configuration: {
sourceRoot: "../README.md",
},
},
"auto",
],
});

This, like any configuration setting, can be done anywhere in the structure.

/docs/robindoc.ts
export const { Page, Sidebar } = initializeRobindoc({
// ...
items: [
{
title: "Structure",
type: "heading",
href: "/02-structure",
items: [
// ...
{
title: "Data Source",
href: "/02-structure/03-data-source",
},
],
},
{
title: "Elements",
type: "heading",
href: "/01-elements",
items: "auto",
},
],
});

In automatic mode, Robindoc first looks for a structure.json file in the current directory.

If the structure.json file is not in the current directory, Robindoc will try to create the structure on its own based on the files in the directory. In this case, it will determine all paths, slugs, as well as the header for the sidebar link. The header is formed according to the same principles as the meta-header. Learn more about getting metadata on the Get Meta page.

structure.json 

structure.json - a file with basic instructions for the current level of documentation. It is stored next to the markdown documentation files.

/blog/02-structure.json
{
"index": {
"title": "Blog"
},
"updates": {
"title": "Updates"
},
"tutorials": {
"title": "Tutorials"
}
}

For each structure element, Robindoc will repeat the process and check if there is a structure.json file. If so, it will include them in the final structure. This continues until no more files are left down the tree.

Previous
Configuration
Next
Data Source
Return to navigation