APIDemo

Workspaces

Workspaces allow you to separate content. A workspace can have its own schema, media files and other configuration. It can be useful when the content has (mostly) no relation to the content in other workspaces. Editors can switch workspaces in the dashboard.

workspace('My workspace', {
  source, schema, color, roots
})

Configuration

Source

A string pointing to a directory in which published content is stored.

// content is stored in the `content` directory
source: './content'

Media directory

A string pointing to a directory in which uploaded files are placed. In case your using alinea to manage web content this will often point to a directory that is made publicly available so an url can be created to download or display the file.

// uploaded files are placed in the `public` folder
mediaDir: './public'

Schema

The Schema describing the content structure. Use the schema method to create one.

Roots

An object containing Root configurations and their keys.

Example workspace

The example workspace that is created with alinea init has the following settings:


  • source: content is stored in json files and can be found in the content directory

  • mediaDir: uploaded files are placed in the public folder

  • schema: the schema includes the default MediaSchema, necessary for file uploads, and a generic Page type

  • roots: defines two separate web roots, one for data (our welcome page in this case), and one for media (file uploads)

workspace('Example', {
  source: './content',
  mediaDir: './public',
  schema: schema({
    ...MediaSchema,
    Page: type('Page',
      {
        title: text('Title'),
        path: path('Path')
      },
      <Welcome />
    ).configure({isContainer: true})
  }),
  roots: {
    data: root('Example project', {
      icon: IcRoundInsertDriveFile,
      contains: ['Page']
    }),
    media: root('Media', {
      icon: IcRoundPermMedia,
      contains: ['MediaLibrary']
    })
  }
})

Types