Most docs.mapbox.com sites use a single structure, which means it documents a single product. But iOS and Android use a multi-structure to document several products (for example the Maps SDK, Navigation SDK, and Plugins).
This guide will walk you through creating a new multi-structured site.
Start by creating a new repository with docs starter kit.
Docs starter kit includes a single-structured site. This means that the contents of src/pages/
all belong to a single product. In this step, you will identify your site's multi-structure and begin building out the files.
/ios/maps/
.src/pages/
using the shortened name. For example: src/pages/maps/
.Your site structure will look something like:
src/
pages/
maps/
navigation/
vision/
Using the path names and titles you identified in the previous step, build a configuration JSON.
Your JSON will look something like:
const subsites = [
{
path: 'maps',
title: 'Maps SDK for iOS'
},
{
path: 'navigation',
title: 'Navigation SDK for iOS'
},
{
path: 'vision',
title: 'Vision SDK for iOS'
}
];
See Shape of multi-structured sections for more options.
batfish.config.js
, below the required packages and above the Batfish configuration function, create a constant, add the subsites
constant you created in the previous step.navigation
in dataSelectors
.sections
argument to the buildNavigation
function to include the subsites
constant you created in the first step:navigation: data => buildNavigation({ siteBasePath, data, sections: subsites }),
See the navigation Batfish data selector for more documentation.
Each subsite's folder now acts as a single-structure site. From the frontmatter of each page, you can define the pages that should appear in the top navigation bar with navOrder
and order each page in that section with order
. See the PageLayout
component guide to learn about more frontmatter fields.
Below is an example of the folder structure for a subsite:
src/
pages/
maps/
examples/
index.md (navOrder: 2)
add-marker.md
clustering.md
help/
index.md (navOrder: 3)
overview/
index.md (navOrder: 1)
mapbox-studio.md
index.js
Most subsites include:
overview/
folder that contains a collection of guides and the homepage for the subsitesrc/maps/overview/index.md
.OverviewHeader
component at the top of the page to define the product for that subsite.index.js
in the subsite's root folder is usually a redirect to the overview homepage:import { prefixUrl } from '@mapbox/batfish/modules/prefix-url';
import { createRedirect } from '@mapbox/dr-ui/helpers/create-redirect';
export default createRedirect(prefixUrl('/maps/overview/'));