Skip to content

Commit

Permalink
Add custom root/entry view to dev project
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Nov 28, 2023
1 parent f4ab065 commit 1cb97c5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
26 changes: 26 additions & 0 deletions apps/dev/cms.ts → apps/dev/cms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ export namespace schema {
}
})

export const CustomPage = alinea.document('Custom page', {
[alinea.meta]: {
view() {
return (
<div style={{width: '100%', height: '100%', background: 'red'}}>
Custom entry view
</div>
)
}
}
})

export const Fields = alinea.document('Fields', {
...alinea.tabs(
alinea.tab('Basic fields', {
Expand Down Expand Up @@ -138,6 +150,20 @@ export const cms = createCMS({
}
}
}),
custom: alinea.root('Custom', {
[alinea.meta]: {
contains: ['CustomPage'],
view() {
return (
<div
style={{width: '100%', height: '100%', background: 'yellow'}}
>
Custom root view
</div>
)
}
}
}),
media: alinea.media(),
[alinea.meta]: {
mediaDir: 'public',
Expand Down
9 changes: 9 additions & 0 deletions apps/dev/content/primary/custom/custom-page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"title": "Custom page",
"@alinea": {
"entryId": "2YnhoPndWwLQXFYJzxk5TOKPzSl",
"type": "CustomPage",
"index": "a0",
"root": "custom"
}
}
5 changes: 3 additions & 2 deletions apps/dev/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"strictNullChecks": true
"strictNullChecks": true,
"jsx": "react-jsx"
},
"include": ["cms.ts"]
"include": ["cms.tsx"]
}
5 changes: 3 additions & 2 deletions src/dashboard/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ function AppAuthenticated() {
<Sidebar.Nav>
{Object.entries(roots).map(([key, root], i) => {
const isSelected = key === currentRoot
const {entryId, ...location} = entryLocation
const link =
entryLocation && entryLocation.root === key
? nav.entry(entryLocation)
location.root === key
? nav.entry(location)
: nav.root({
workspace,
root: key,
Expand Down

0 comments on commit 1cb97c5

Please sign in to comment.