Skip to content

Commit

Permalink
Move createCMS to alinea/core and update init command and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Feb 2, 2024
1 parent 5ffdfae commit 8499107
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 50 deletions.
4 changes: 2 additions & 2 deletions apps/demo/src/cms.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createNextCMS} from 'alinea/next'
import {createCMS} from 'alinea/next'
import {config} from '../alinea.config'

export const cms = createNextCMS(config)
export const cms = createCMS(config)
4 changes: 2 additions & 2 deletions apps/dev/cms.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import alinea, {createCMS} from 'alinea'
import {Entry} from 'alinea/core'
import alinea from 'alinea'
import {Entry, createCMS} from 'alinea/core'
import {IcRoundTranslate} from 'alinea/ui/icons/IcRoundTranslate'
import {IcRoundUploadFile} from 'alinea/ui/icons/IcRoundUploadFile'
import {position} from './src/PositionField'
Expand Down
12 changes: 1 addition & 11 deletions apps/web/content/pages/docs/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,11 @@
{
"id": "2a4tC7lBmNMZUuJDec7zsG4st62",
"type": "CodeBlock",
"code": "import {createNextCMS} from 'alinea'\n\nexport const cms = createNextCMS({\n workspaces, schema, dashboard, preview\n})",
"code": "import {createCMS} from 'alinea/next'\n\nexport const cms = createCMS({\n workspaces, schema, dashboard, preview\n})",
"fileName": "cms.tsx",
"language": "",
"compact": false
},
{
"type": "paragraph",
"textAlign": "left",
"content": [
{
"type": "text",
"text": "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."
}
]
},
{
"type": "heading",
"textAlign": "left",
Expand Down
5 changes: 3 additions & 2 deletions apps/web/content/pages/docs/deploy.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"title": "Deploy",
"navigationTitle": "",
"body": [
{
"type": "paragraph",
Expand Down Expand Up @@ -66,7 +67,7 @@
{
"id": "2YlDwmJLzaL93bp5gYZmshbJG1P",
"type": "CodeBlock",
"code": "export const cms = createNextCMS({\n // schema and workspaces ...\n dashboard: {\n handlerUrl: '/api/cms',\n staticFile: 'public/admin.html',\n dashboardUrl: '/admin.html'\n }\n})",
"code": "export const cms = createCMS({\n // schema and workspaces ...\n dashboard: {\n handlerUrl: '/api/cms',\n staticFile: 'public/admin.html',\n dashboardUrl: '/admin.html'\n }\n})",
"fileName": "",
"language": "",
"compact": false
Expand Down Expand Up @@ -99,4 +100,4 @@
"type": "Docs",
"index": "Zp"
}
}
}
2 changes: 1 addition & 1 deletion src/cli/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function init(options: InitOptions) {
'utf-8'
)
const configFileContents = options.next
? configFile.replaceAll('createCMS', 'createNextCMS')
? configFile.replaceAll('alinea/core', 'alinea/next')
: configFile
const hasSrcDir = (await outcome(fs.stat(path.join(cwd, 'src')))).isSuccess()
const configFileLocation = path.join(
Expand Down
63 changes: 32 additions & 31 deletions src/cli/static/init/cms.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import alinea, {createCMS} from 'alinea'

const Page = alinea.type('Page', {
title: alinea.text('Title'),
path: alinea.path('Path')
})

export const cms = createCMS({
schema: {
Page
},
workspaces: {
main: alinea.workspace('Example', {
pages: alinea.root('Example project', {
welcome: alinea.page(
Page({
title: 'Welcome'
})
),
[alinea.meta]: {
contains: ['Page']
}
}),
media: alinea.media(),
[alinea.meta]: {
source: 'content',
mediaDir: 'public'
}
})
}
})
import alinea from 'alinea'
import {createCMS} from 'alinea/core'

const Page = alinea.type('Page', {
title: alinea.text('Title'),
path: alinea.path('Path')
})

export const cms = createCMS({
schema: {
Page
},
workspaces: {
main: alinea.workspace('Example', {
pages: alinea.root('Example project', {
welcome: alinea.page(
Page({
title: 'Welcome'
})
),
[alinea.meta]: {
contains: ['Page']
}
}),
media: alinea.media(),
[alinea.meta]: {
source: 'content',
mediaDir: 'public'
}
})
}
})
1 change: 1 addition & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export * from './core/Type.js'
export * from './core/User.js'
export * from './core/View.js'
export * from './core/Workspace.js'
export {createCMS} from './core/driver/DefaultDriver.js'
export * from './core/field/ListField.js'
export * from './core/field/RecordField.js'
export * from './core/field/RichTextField.js'
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ export {createNextCMS}
/** @deprecated Use import {createCMS} from 'alinea/next' instead */
const createNextCMS = _createNextCMS

export * from 'alinea/core/driver/DefaultDriver'
// Default CMS constructor - deprecated
import {createCMS as _createCMS} from 'alinea/core/driver/DefaultDriver'
export {createCMS}
/** @deprecated Use import {createCMS} from 'alinea/core' instead */
const createCMS = _createCMS

0 comments on commit 8499107

Please sign in to comment.