Creating a CMS instance

All configuration can be managed by creating a CMS instance. The alinea package exports a general purpose createCMS function as well as framework specific functions such as createNextCMS. The framework specific instances expose helper methods to help integrate the content into your framework of choice.

All configuration can be managed from the alinea.config.tsx file. This file is created during alinea init. It contains an example workspace to get started from.

If you prefer plain Javascript over Typescript, just rename the file to alinea.config.js

Example config

In the example below we find a schema which includes the default MediaSchema, necessary for file uploads, and a generic Page type. One workspace named main is defined with 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

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

alinea.config.tsx
import {Welcome} from 'alinea/dashboard/Welcome'
import {IcRoundInsertDriveFile} from 'alinea/ui/icons/IcRoundInsertDriveFile'
import {IcRoundPermMedia} from 'alinea/ui/icons/IcRoundPermMedia'
import {alinea} from 'alinea'

export const config = alinea.createConfig({
  schema: alinea.schema({
    ...alinea.MediaSchema,
    Page: alinea.type(
      'Page',
      {
        title: alinea.text('Title'),
        path: alinea.path('Path')
      },
      <Welcome />
    )
  }),
  workspaces: {
    main: alinea.workspace('Example', {
      source: './content',
      mediaDir: './public',
      roots: {
        data: alinea.root('Example project', {
          icon: IcRoundInsertDriveFile,
          contains: ['Page']
        }),
        media: alinea.root('Media', {
          icon: IcRoundPermMedia,
          contains: ['MediaLibrary']
        })
      }
    })
  }
})