Skip to content

v0.11.0

Compare
Choose a tag to compare
@github-actions github-actions released this 11 Oct 11:38
b245426
  • The cms handler has been rewritten to handle both backend and previews. This
    requires updating your handler route. In the case of Next.js you can replace
    both app/api/cms/[...slug]/route.ts and /app/api/preview.ts with the
    following:

    // app/api/cms/route.ts
    import {cms} from '@/cms'
    import {createHandler} from 'alinea/next'
    
    const handler = createHandler(cms)
    
    export const GET = handler
    export const POST = handler

    This release also requires you to restructure your Alinea config file.
    The dashboard property is replaced by the baseUrl, handlerUrl and
    dashboardFile properties.

    // cms.tsx
    
    // Previously:
    const cms = createCMS({
      // ... schema and workspaces
      dashboard: {
        dashboardUrl: '/admin.html',
        handlerUrl: '/api/cms',
        staticFile: 'public/admin.html'
      },
      preview:
        process.env.NODE_ENV === 'development'
          ? 'http://localhost:3000/api/preview'
          : '/api/preview'
    })
    
    // Becomes:
    const cms = createCMS({
      // ... schema and workspaces
      baseUrl: {
        // Point this to your local frontend
        development: 'http://localhost:3000'
        // If hosting on vercel you can use: process.env.VERCEL_URL
        production: 'http://example.com'
      },
      handlerUrl: '/api/cms',
      dashboardFile: 'admin.html',
      // Optionally supply the public folder with
      publicDir: 'public',
      // Enable previews which are handled via handlerUrl
      preview: true
    })