diff --git a/bin/tailcms.js b/bin/tailcms.js index 1f51533..9211e8d 100644 --- a/bin/tailcms.js +++ b/bin/tailcms.js @@ -3,7 +3,7 @@ import { readdir, writeFile, mkdir } from 'fs/promises'; import path from 'path'; import { createApp } from '../src/app.js'; -import { createFileDb } from 'svelite-html/db'; +import { createFileDb, createMemoryDb } from 'svelite-html/db'; import { existsSync, mkdirSync } from 'fs'; import { chdir } from 'process'; @@ -112,6 +112,8 @@ async function runDev(cwd) { if (config.db.type === 'file') { const { type, ...rest } = config.db; db = createFileDb(rest); + } else { + db = createMemoryDb({}) } const port = process.env.TAILCMS_PORT ?? 3000; diff --git a/index.js b/index.js index 98b2375..2961d05 100644 --- a/index.js +++ b/index.js @@ -14,4 +14,6 @@ const {PORT = 3000} = process.env const db = createFileDb({path: './data.json'}) +console.log({db}) + createApp({functions, db}).listen(PORT, () => console.log('app started on http://localhost:' + PORT)) \ No newline at end of file diff --git a/package.json b/package.json index e44fec3..b423825 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "#helpers": "./src/helpers.js" }, "scripts": { + "start": "node bin/tailcms.js dev", "dev": "node bin/tailcms.js dev", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/public/js/setup.js b/public/js/setup.js index 4bc2405..d4593df 100644 --- a/public/js/setup.js +++ b/public/js/setup.js @@ -1,12 +1,14 @@ -import { setFormValue } from "/js/form.js"; +// import { setFormValue } from "/js/helpers.js"; +// import { Form } from "/js/form.js"; // import { FileUploader } from './fileuploader.js' +// Form(document.querySelector('[data-form]')) // FileUploader(document.querySelector('[data-file-label]')) document.querySelector('[data-form]').action = '/api/setup' document.querySelector('[data-form]').method = 'POST' -setFormValue(document.querySelector('[data-form]'), { - password: 'Passw0rd!', -}) \ No newline at end of file +// setFormValue(document.querySelector('[data-form]'), { +// password: 'Passw0rd!', +// }) \ No newline at end of file diff --git a/services/db.js b/services/db.js index 3e2a144..f5694e0 100644 --- a/services/db.js +++ b/services/db.js @@ -5,6 +5,7 @@ import { createFileDb, createMongoDb } from 'svelite-html/db' // const db = createMongoDb({uri: 'mongodb://127.0.0.1:27017', db:'SiteBuilder'}) export function setDb(value) { + console.log('setdb', value) db = value } diff --git a/src/handlers/page.js b/src/handlers/page.js index f34a571..f4a1ce4 100644 --- a/src/handlers/page.js +++ b/src/handlers/page.js @@ -61,7 +61,7 @@ export default { await db('pages').insert(body) return { - redirect: '/admin?view=pages.edit&slug=' + encodeURIComponent(body.slug) + redirect: '/admin?view=pages.edit&id=' + body.id } }, async load(body) { diff --git a/src/layouts.js b/src/layouts.js index 4f8930a..c3e2b9d 100644 --- a/src/layouts.js +++ b/src/layouts.js @@ -41,6 +41,10 @@ export default { {{{head}}} {{/eq}} + {{#eq mode 'setup'}} + {{{head}}} + {{/eq}} +