@alstar/studio 0.0.0-beta.5 → 0.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/api-key.ts +74 -0
- package/api/block.ts +82 -42
- package/api/index.ts +9 -1
- package/api/mcp.ts +53 -0
- package/components/AdminPanel.ts +74 -0
- package/components/BlockFieldRenderer.ts +121 -0
- package/components/BlockRenderer.ts +22 -0
- package/components/Entries.ts +5 -4
- package/components/Entry.ts +13 -21
- package/components/FieldRenderer.ts +35 -0
- package/components/Render.ts +46 -0
- package/components/Settings.ts +98 -0
- package/components/{layout.ts → SiteLayout.ts} +9 -13
- package/components/fields/Markdown.ts +44 -0
- package/components/fields/Text.ts +42 -0
- package/components/fields/index.ts +4 -0
- package/components/icons.ts +59 -0
- package/index.ts +52 -30
- package/package.json +3 -2
- package/pages/entry/[id].ts +17 -0
- package/{components → pages}/index.ts +7 -4
- package/pages/settings.ts +10 -0
- package/public/studio/admin-panel.css +103 -0
- package/public/studio/blocks.css +53 -0
- package/public/studio/main.css +162 -0
- package/public/studio/main.js +10 -0
- package/public/studio/markdown-editor.js +34 -0
- package/public/studio/settings.css +24 -0
- package/public/studio/sortable-list.js +40 -0
- package/queries/block-with-children.ts +74 -0
- package/queries/block.ts +31 -40
- package/queries/db-types.ts +15 -0
- package/queries/getBlockTrees-2.ts +0 -0
- package/queries/getBlockTrees.ts +316 -0
- package/queries/getBlocks.ts +214 -0
- package/queries/index.ts +1 -0
- package/queries/structure-types.ts +97 -0
- package/schemas.ts +14 -3
- package/types.ts +123 -6
- package/utils/buildBlocksTree.ts +4 -4
- package/utils/define.ts +31 -5
- package/utils/file-based-router.ts +1 -0
- package/utils/get-or-create-row.ts +41 -0
- package/utils/startup-log.ts +9 -0
- package/components/AdminPanel/AdminPanel.css +0 -78
- package/components/AdminPanel/AdminPanel.ts +0 -57
- package/components/Block.ts +0 -116
- package/components/Field.ts +0 -168
- package/components/Fields.ts +0 -43
- package/public/main.css +0 -95
- package/public/main.js +0 -44
- /package/{components/Entry.css → public/studio/entry.css} +0 -0
- /package/public/{favicon.svg → studio/favicon.svg} +0 -0
package/components/Field.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { html } from 'hono/html'
|
|
2
|
-
import { type Block } from '../types.ts'
|
|
3
|
-
import { type HtmlEscapedString } from 'hono/utils/html'
|
|
4
|
-
import { query } from '../queries/index.ts'
|
|
5
|
-
import { db } from '@alstar/db'
|
|
6
|
-
import BlockComponent from './Block.ts'
|
|
7
|
-
import {
|
|
8
|
-
buildStructurePath,
|
|
9
|
-
type StructurePath,
|
|
10
|
-
} from '../utils/build-structure-path.ts'
|
|
11
|
-
|
|
12
|
-
function getData(parentId: string | number, field: Block, sortOrder: number) {
|
|
13
|
-
const data = query.block({
|
|
14
|
-
parent_block_id: parentId?.toString() || null,
|
|
15
|
-
name: field.name,
|
|
16
|
-
sort_order: sortOrder.toString(),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
if (!data) {
|
|
20
|
-
const change = db.insertInto('blocks', {
|
|
21
|
-
name: field.name?.toString(),
|
|
22
|
-
label: field.label?.toString(),
|
|
23
|
-
type: field.type?.toString(),
|
|
24
|
-
sort_order: sortOrder,
|
|
25
|
-
parent_block_id: parentId,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return query.block({ id: change.lastInsertRowid.toString() })
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return data
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Field = (props: {
|
|
35
|
-
entryId: string | number
|
|
36
|
-
parentId: string | number
|
|
37
|
-
blockStructure: Block
|
|
38
|
-
sortOrder?: number
|
|
39
|
-
structurePath: StructurePath
|
|
40
|
-
}): HtmlEscapedString | Promise<HtmlEscapedString> => {
|
|
41
|
-
const {
|
|
42
|
-
entryId,
|
|
43
|
-
parentId,
|
|
44
|
-
blockStructure,
|
|
45
|
-
sortOrder = 0,
|
|
46
|
-
structurePath,
|
|
47
|
-
} = props
|
|
48
|
-
|
|
49
|
-
const data = getData(parentId, blockStructure, sortOrder)
|
|
50
|
-
|
|
51
|
-
if (!data) return html`<p>No block</p>`
|
|
52
|
-
|
|
53
|
-
const fieldStructurePath = buildStructurePath(blockStructure, structurePath)
|
|
54
|
-
|
|
55
|
-
return html`
|
|
56
|
-
${blockStructure.type === 'slug' &&
|
|
57
|
-
html`
|
|
58
|
-
<form
|
|
59
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
60
|
-
>
|
|
61
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
62
|
-
<input
|
|
63
|
-
id="block-${data.id}"
|
|
64
|
-
name="value"
|
|
65
|
-
type="text"
|
|
66
|
-
value="${data.value}"
|
|
67
|
-
/>
|
|
68
|
-
|
|
69
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
70
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
71
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
72
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
73
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
74
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
75
|
-
<input
|
|
76
|
-
type="hidden"
|
|
77
|
-
name="path"
|
|
78
|
-
value="${fieldStructurePath.join('.')}"
|
|
79
|
-
/>
|
|
80
|
-
</form>
|
|
81
|
-
`}
|
|
82
|
-
${blockStructure.type === 'text' &&
|
|
83
|
-
html`
|
|
84
|
-
<form
|
|
85
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
86
|
-
>
|
|
87
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
88
|
-
<input
|
|
89
|
-
id="block-${data.id}"
|
|
90
|
-
name="value"
|
|
91
|
-
type="text"
|
|
92
|
-
value="${data.value}"
|
|
93
|
-
/>
|
|
94
|
-
|
|
95
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
96
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
97
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
98
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
99
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
100
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
101
|
-
<input
|
|
102
|
-
type="hidden"
|
|
103
|
-
name="path"
|
|
104
|
-
value="${fieldStructurePath.join('.')}"
|
|
105
|
-
/>
|
|
106
|
-
</form>
|
|
107
|
-
`}
|
|
108
|
-
${blockStructure.type === 'image' &&
|
|
109
|
-
html`
|
|
110
|
-
<form
|
|
111
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
112
|
-
>
|
|
113
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
114
|
-
<input
|
|
115
|
-
id="block-${data.id}"
|
|
116
|
-
name="value"
|
|
117
|
-
type="text"
|
|
118
|
-
value="${data.value}"
|
|
119
|
-
/>
|
|
120
|
-
|
|
121
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
122
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
123
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
124
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
125
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
126
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
127
|
-
<input
|
|
128
|
-
type="hidden"
|
|
129
|
-
name="path"
|
|
130
|
-
value="${fieldStructurePath.join('.')}"
|
|
131
|
-
/>
|
|
132
|
-
</form>
|
|
133
|
-
`}
|
|
134
|
-
${blockStructure.type === 'markdown' &&
|
|
135
|
-
html`
|
|
136
|
-
<form
|
|
137
|
-
data-on-input="@patch('/admin/api/block', { contentType: 'form' })"
|
|
138
|
-
>
|
|
139
|
-
<label for="block-${data.id}">${blockStructure.label}</label>
|
|
140
|
-
|
|
141
|
-
<textarea></textarea>
|
|
142
|
-
|
|
143
|
-
<!-- <input
|
|
144
|
-
id="block-${data.id}"
|
|
145
|
-
name="value"
|
|
146
|
-
type="text"
|
|
147
|
-
value="${data.value}"
|
|
148
|
-
/> -->
|
|
149
|
-
|
|
150
|
-
<input type="hidden" name="type" value="${blockStructure.type}" />
|
|
151
|
-
<input type="hidden" name="id" value="${data.id}" />
|
|
152
|
-
<input type="hidden" name="entryId" value="${entryId}" />
|
|
153
|
-
<input type="hidden" name="parentId" value="${parentId}" />
|
|
154
|
-
<input type="hidden" name="sort_order" value="${sortOrder}" />
|
|
155
|
-
<input type="hidden" name="name" value="${blockStructure.name}" />
|
|
156
|
-
<input
|
|
157
|
-
type="hidden"
|
|
158
|
-
name="path"
|
|
159
|
-
value="${fieldStructurePath.join('.')}"
|
|
160
|
-
/>
|
|
161
|
-
</form>
|
|
162
|
-
`}
|
|
163
|
-
${blockStructure.type === 'blocks' &&
|
|
164
|
-
BlockComponent(entryId, data.id, blockStructure, fieldStructurePath)}
|
|
165
|
-
`
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export default Field
|
package/components/Fields.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { html } from 'hono/html'
|
|
2
|
-
import { type Block } from '../types.ts'
|
|
3
|
-
import { type HtmlEscapedString } from 'hono/utils/html'
|
|
4
|
-
import Field from './Field.ts'
|
|
5
|
-
import {
|
|
6
|
-
buildStructurePath,
|
|
7
|
-
type StructurePath,
|
|
8
|
-
} from '../utils/build-structure-path.ts'
|
|
9
|
-
|
|
10
|
-
const Fields = (props: {
|
|
11
|
-
entryId: string | number
|
|
12
|
-
parentId: string | number
|
|
13
|
-
blockStructure: Block
|
|
14
|
-
structurePath: StructurePath
|
|
15
|
-
}): HtmlEscapedString | Promise<HtmlEscapedString> => {
|
|
16
|
-
const updatedPath = buildStructurePath(
|
|
17
|
-
props.blockStructure,
|
|
18
|
-
props.structurePath,
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
return html`
|
|
22
|
-
<div class="fields">
|
|
23
|
-
${props.blockStructure.fields
|
|
24
|
-
? props.blockStructure.fields?.map((field, idx) => {
|
|
25
|
-
return Field({
|
|
26
|
-
entryId: props.entryId,
|
|
27
|
-
parentId: props.parentId,
|
|
28
|
-
blockStructure: field,
|
|
29
|
-
sortOrder: idx,
|
|
30
|
-
structurePath: [...updatedPath, 'fields'],
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
: Field({
|
|
34
|
-
entryId: props.entryId,
|
|
35
|
-
parentId: props.parentId,
|
|
36
|
-
blockStructure: props.blockStructure,
|
|
37
|
-
structurePath: updatedPath,
|
|
38
|
-
})}
|
|
39
|
-
</div>
|
|
40
|
-
`
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default Fields
|
package/public/main.css
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/* @import './../node_modules/@alstar/ui/red.css'; */
|
|
2
|
-
@import 'https://esm.sh/@alstar/ui/red.css';
|
|
3
|
-
|
|
4
|
-
body {
|
|
5
|
-
min-height: 100vh;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
body {
|
|
9
|
-
padding: 0;
|
|
10
|
-
min-height: inherit;
|
|
11
|
-
|
|
12
|
-
display: grid;
|
|
13
|
-
grid-template-columns: auto 1fr;
|
|
14
|
-
align-content: baseline;
|
|
15
|
-
|
|
16
|
-
> main {
|
|
17
|
-
padding: 40px;
|
|
18
|
-
height: 100vh;
|
|
19
|
-
overflow: auto;
|
|
20
|
-
|
|
21
|
-
section {
|
|
22
|
-
max-width: 900px;
|
|
23
|
-
margin: 0 auto;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.entry > .fields > .block {
|
|
29
|
-
padding-block: var(--pico-spacing);
|
|
30
|
-
|
|
31
|
-
> header {
|
|
32
|
-
margin-block: var(--pico-block-spacing-vertical);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.block {
|
|
37
|
-
> header {
|
|
38
|
-
margin-bottom: var(--pico-spacing);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
header {
|
|
42
|
-
display: flex;
|
|
43
|
-
justify-content: space-between;
|
|
44
|
-
align-items: center;
|
|
45
|
-
|
|
46
|
-
background-color: inherit;
|
|
47
|
-
|
|
48
|
-
h6,
|
|
49
|
-
h5,
|
|
50
|
-
fieldset {
|
|
51
|
-
margin-bottom: 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
button {
|
|
55
|
-
padding: 0;
|
|
56
|
-
background-color: white;
|
|
57
|
-
|
|
58
|
-
svg {
|
|
59
|
-
padding: 8px;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
[data-sortable] {
|
|
66
|
-
> article {
|
|
67
|
-
transition: opacity 200ms;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.sortable-ghost {
|
|
71
|
-
opacity: 0.3;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/* .sortable-chosen {
|
|
75
|
-
filter: brightness(0.9)
|
|
76
|
-
} */
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
div.ink-mde {
|
|
80
|
-
border: var(--pico-border-width) solid #2a3140;
|
|
81
|
-
border-radius: var(--pico-border-radius);
|
|
82
|
-
outline: 0;
|
|
83
|
-
background-color: var(--pico-background-color);
|
|
84
|
-
box-shadow: var(--pico-box-shadow);
|
|
85
|
-
color: var(--pico-color);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.ink-mde-textarea {
|
|
89
|
-
width: 100%;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.disclamer {
|
|
93
|
-
display: flex;
|
|
94
|
-
justify-content: center;
|
|
95
|
-
}
|
package/public/main.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import barba from '@barba/core'
|
|
2
|
-
import Sortable from 'sortablejs'
|
|
3
|
-
// import { wrap } from 'ink-mde'
|
|
4
|
-
|
|
5
|
-
barba.init({
|
|
6
|
-
views: [
|
|
7
|
-
{
|
|
8
|
-
namespace: 'default',
|
|
9
|
-
afterEnter() {
|
|
10
|
-
init()
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
function init() {
|
|
17
|
-
// sortable
|
|
18
|
-
{
|
|
19
|
-
const els = document.querySelectorAll('[data-sortable]')
|
|
20
|
-
|
|
21
|
-
els.forEach((el) => {
|
|
22
|
-
var sortable = Sortable.create(el, {
|
|
23
|
-
delay: 0,
|
|
24
|
-
animation: 250,
|
|
25
|
-
dragClass: 'sortable-drag',
|
|
26
|
-
easing: 'ease-in-out',
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// // ink-mde
|
|
32
|
-
// {
|
|
33
|
-
// const el = document.querySelector('textarea')
|
|
34
|
-
|
|
35
|
-
// if (el) {
|
|
36
|
-
// wrap(el, {
|
|
37
|
-
// interface: {
|
|
38
|
-
// // appearance: InkValues.Appearance.Auto,
|
|
39
|
-
// attribution: false,
|
|
40
|
-
// },
|
|
41
|
-
// })
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
}
|
|
File without changes
|
|
File without changes
|