Roots

    Roots help you organize content hierarchically in a tree. Pages can have subpages, subpages can have sub-subpages and so on. This hierarchy starts at a Root.

    import {Config} from 'alinea'
    
    Config.root('Pages', {
      i18n: {
        locales: ['en', 'fr', 'nl']
      },
      preview: true,
      contains: ['HomePage', 'GenericPage'],
      children: {
        index: Config.page({
          type: HomePage,
          fields: {title: 'Home'}
        }),
        'about-us': Config.page({
          type: GenericPage,
          fields: {title: 'About us'}
        })
      }
    })

    Configuration

    Roots should be defined within a Workspace.

    i18n

    An object with internationalization configuration. Locales is an array of strings, containing locales described by a key that will, by default, show up in the url structure as well.

    i18n: {
      locales: ['en', 'fr', 'nl']
    }

    icon

    An icon can be used to label a root in the sidebar. Icons are implemented as a React component. You can find icons on Icones or install a package such as react-icons.

    preview

    Display an iframe with live previews on the side of the editor.

    contains

    An array of strings containing the names of types that can be created at the root.

    // only entries of type Page can be created at the top of the tree
    contains: ['GenericPage']

    children

    Defines child entries that can be automatically seeded with predefined types and fields.
    The first object sets the path field. To create an empty path (for a homepage), set the path to index.

    children: {
      index: Config.page({
        type: HomePage,
        fields: {title: 'Home'}
      })
    }