Skip to content

Commit e492f62

Browse files
committed
fixing for 0.0.15 release, with [email protected]
1 parent 71b1579 commit e492f62

File tree

11 files changed

+72
-26
lines changed

11 files changed

+72
-26
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sveltecms",
3-
"version": "0.0.14",
3+
"version": "0.0.15",
44
"scripts": {
55
"debug": "echo 'To debug, open Google Chrome to chrome://inspect' && node --inspect node_modules/.bin/vite dev",
66
"dev": "vite dev",

package/CMSAdmin.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let adminPage;
1111
let adminPagePromise;
1212
$: basePath = $page.url.pathname.replace('/' + adminPath, '');
1313
$: if (adminPath)
14-
adminPagePromise = (async () => { console.log(cms.getAdminPage(adminPath)); adminPage = cms.getAdminPage(adminPath); })();
14+
adminPagePromise = (async () => { adminPage = cms.getAdminPage(adminPath); })();
1515
$: title = adminPage ? adminPath.split('/').map((t, i) => adminPage.label[i] || getLabelFromID(t)).join(' : ') : 'Site Admin';
1616
</script>
1717

package/CMSEditorForm.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export let submitOptions = {};
1414
export let isNew = undefined;
1515
export const contentType = cms.getContentType(contentTypeID);
1616
let widgetFieldGroup = cms.getWidgetFields(contentType, { values, errors, touched });
17-
export let action = contentType?.form?.action ?? '';
17+
export let action = contentType?.form?.action ?? '?/post';
1818
export let method = contentType?.form?.method ?? 'POST';
1919
values['_oldSlug'] = values['_slug'] ?? '';
2020
const initialValues = cloneDeep(values);

package/install/routes/(cms)/admin/[...adminPath]/+page.server.ts

+26-16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const prerender = false
22

33
import cms from '$lib/cms'
44
import { error, type RequestEvent } from '@sveltejs/kit'
5+
import type { Actions } from './$types'
56
import admin from 'sveltecms/plugins/admin'
67
cms.use(admin)
78

@@ -17,26 +18,35 @@ export async function load(event:RequestEvent) {
1718
return { data }
1819
}
1920

20-
export async function POST(event:RequestEvent) {
21+
export const actions:Actions = {
2122

22-
const { params } = event
23-
const args = params.adminPath.split('/')
24-
const adminPage = cms.getAdminPage(params.adminPath)
23+
post: async (event) => {
24+
const { params } = event
25+
const args = params.adminPath.split('/')
26+
const adminPage = cms.getAdminPage(params.adminPath)
2527

26-
if (!adminPage || !adminPage.POST) throw error(405)
28+
console.log(adminPage)
2729

28-
let data = await adminPage.POST({cms, args, event})
29-
return { data }
30-
}
30+
if (!adminPage) throw error(404)
3131

32-
export async function DELETE(event:RequestEvent) {
32+
if (!adminPage.POST) throw error(405)
3333

34-
const { params } = event
35-
const args = params.adminPath.split('/')
36-
const adminPage = cms.getAdminPage(params.adminPath)
34+
let data = await adminPage.POST({cms, args, event})
35+
return { data }
36+
},
3737

38-
if (!adminPage || !adminPage.DELETE) throw error(405)
38+
delete: async (event) => {
3939

40-
let data = await adminPage.DELETE({cms, args, event})
41-
return { data }
42-
}
40+
const { params } = event
41+
const args = params.adminPath.split('/')
42+
const adminPage = cms.getAdminPage(params.adminPath)
43+
44+
if (!adminPage) throw error(404)
45+
if (!adminPage.DELETE) throw error(405)
46+
47+
let data = await adminPage.DELETE({cms, args, event})
48+
return { data }
49+
50+
}
51+
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import cms from "$lib/cms"
2+
import { error, type ServerLoad } from "@sveltejs/kit"
3+
import admin from 'sveltecms/plugins/admin'
4+
cms.use(admin)
5+
6+
export const POST:ServerLoad = async (event) => {
7+
8+
const { params } = event
9+
const args = params.adminPath.split('/')
10+
const adminPage = cms.getAdminPage(params.adminPath)
11+
12+
console.log(adminPage)
13+
14+
if (!adminPage) throw error(404)
15+
16+
if (!adminPage.POST) throw error(405)
17+
18+
let data = await adminPage.POST({cms, args, event})
19+
return { data }
20+
21+
}
22+
23+
export const DELETE:ServerLoad = async (event) => {
24+
const { params } = event
25+
const args = params.adminPath.split('/')
26+
const adminPage = cms.getAdminPage(params.adminPath)
27+
28+
if (!adminPage) throw error(404)
29+
if (!adminPage.DELETE) throw error(405)
30+
31+
let data = await adminPage.DELETE({cms, args, event})
32+
return { data }
33+
34+
}

package/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "sveltecms",
3-
"version": "0.0.14",
3+
"version": "0.0.15",
44
"dependencies": {
55
"@isomorphic-git/lightning-fs": "^4.4.1",
66
"@sindresorhus/slugify": "^2.1.0",
7-
"@sveltejs/kit": "1.0.0-next.471",
8-
"@sveltejs/package": "^1.0.0-next.3",
7+
"@sveltejs/kit": "1.0.0-next.510",
8+
"@sveltejs/package": "^1.0.0-next.5",
99
"browser-or-node": "^2.0.0",
1010
"bytes": "^3.1.2",
1111
"cp-file": "^9.1.0",
@@ -31,7 +31,7 @@
3131
},
3232
"devDependencies": {
3333
"@rollup/plugin-yaml": "^3.1.0",
34-
"@sveltejs/adapter-static": "^1.0.0-next.42",
34+
"@sveltejs/adapter-static": "^1.0.0-next.44",
3535
"@tailwindcss/aspect-ratio": "^0.4.0",
3636
"@tailwindcss/line-clamp": "^0.4.0",
3737
"@tailwindcss/typography": "^0.5.2",

package/scripts/postinstall.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const files = [
1717
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+page.svelte`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+page.svelte`],
1818
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+page.ts`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+page.ts`],
1919
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+page.server.ts`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+page.server.ts`],
20+
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+server.ts`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+server.ts`],
2021
[`${fromPath}/routes/(cms)/admin/+layout.svelte`, `${toPath}/src/routes/(cms)/admin/+layout.svelte`],
2122
// Files for the $lib folder
2223
[`${fromPath}/cms.ts`, `${toPath}/src/lib/cms.ts`],

package/ui/Nav.svelte

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ $: crumbs = adminPath.split('/').reduce((agg, val, i, arr) => {
1313
}
1414
return agg;
1515
}, [['admin', '']]);
16-
$: console.log(basePath);
1716
</script>
1817

1918
<nav>

scripts/postpackage.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const files = [
2323
['src/routes/(cms)/admin/[...adminPath]/+page.server.ts', 'package/install/routes/(cms)/admin/[...adminPath]/+page.server.ts'],
2424
['src/routes/(cms)/admin/[...adminPath]/+page.ts', 'package/install/routes/(cms)/admin/[...adminPath]/+page.ts'],
2525
['src/routes/(cms)/admin/[...adminPath]/+page.svelte', 'package/install/routes/(cms)/admin/[...adminPath]/+page.svelte'],
26+
['src/routes/(cms)/admin/[...adminPath]/+server.ts', 'package/install/routes/(cms)/admin/[...adminPath]/+server.ts'],
2627

2728
// Files for the $lib folder
2829
['src/install/cms.ts', 'package/install/cms.ts'],

src/sveltecms/core/Component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ export const templateComponent:EntityTemplate = {
2121

2222
export type ComponentType = EntityType & ConfigurableEntityType & {
2323
admin?:true
24-
component:ConstructorOfATypedSvelteComponent // TODO: find type for svelte component
24+
component:Object // TODO: find type for svelte component
2525
}
2626

2727
export type ComponentConfigSetting = TypedEntityConfigSetting & ConfigurableEntityConfigSetting
2828

2929
export class Component implements ConfigurableEntity, TypedEntity {
3030
id: string
3131
type: string
32-
component: ConstructorOfATypedSvelteComponent
32+
component: Object
3333
admin?:true
3434
plugin?:string
3535
options?: ConfigSetting

src/sveltecms/scripts/postinstall.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const files = [
2121
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+page.svelte`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+page.svelte`],
2222
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+page.ts`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+page.ts`],
2323
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+page.server.ts`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+page.server.ts`],
24+
[`${fromPath}/routes/(cms)/admin/[...adminPath]/+server.ts`, `${toPath}/src/routes/(cms)/admin/[...adminPath]/+server.ts`],
2425
[`${fromPath}/routes/(cms)/admin/+layout.svelte`, `${toPath}/src/routes/(cms)/admin/+layout.svelte`],
2526

2627
// Files for the $lib folder

0 commit comments

Comments
 (0)