Skip to content

Commit 0b4068b

Browse files
authored
refactor(studio): separation of concern between app and module (#91)
1 parent 60f9f72 commit 0b4068b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1089
-740
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script setup lang="ts">
2+
const { data } = await useAsyncData('pages', () => queryCollection('custom').first())
3+
</script>
4+
5+
<template>
6+
<div>
7+
<ContentRenderer :value="data" />
8+
</div>
9+
</template>

playground/docus/content.config.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { DefinedCollection } from '@nuxt/content'
2+
import { defineContentConfig, defineCollection, z } from '@nuxt/content'
3+
4+
const createDocsSchema = () => z.object({
5+
layout: z.string().optional(),
6+
links: z.array(z.object({
7+
label: z.string(),
8+
icon: z.string(),
9+
to: z.string(),
10+
target: z.string().optional(),
11+
})).optional(),
12+
})
13+
14+
const collections: Record<string, DefinedCollection> = {
15+
custom: defineCollection({
16+
type: 'page',
17+
source: {
18+
include: '3.custom-case/**/*.md',
19+
prefix: '/',
20+
},
21+
}),
22+
landing: defineCollection({
23+
type: 'page',
24+
source: {
25+
include: 'index.md',
26+
},
27+
}),
28+
docs: defineCollection({
29+
type: 'page',
30+
source: {
31+
include: '**',
32+
exclude: ['index.md', '3.custom-case/**/*.md'],
33+
},
34+
schema: createDocsSchema(),
35+
}),
36+
}
37+
38+
export default defineContentConfig({ collections })
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Test
3+
description: Test
4+
navigation:
5+
icon: i-lucide-test
6+
---
7+
8+
This test file is corresponding to a custom case collection:
9+
10+
```[content.config.ts]
11+
pages: defineCollection({
12+
type: 'page',
13+
source: {
14+
include: '3.custom-case/**/*.md',
15+
prefix: '/',
16+
},
17+
}),
18+
```

src/app/src/app.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ watch(ui.sidebar.sidebarWidth, () => {
2525
// Nuxt UI Portal element
2626
const appPortal = ref<HTMLElement>()
2727
28-
const activeDocuments = ref<{ id: string, title: string }[]>([])
28+
const activeDocuments = ref<{ fsPath: string, title: string }[]>([])
2929
function detectActiveDocuments() {
3030
activeDocuments.value = host.document.detectActives().map((content) => {
3131
return {
32-
id: content.id,
32+
fsPath: content.fsPath,
3333
title: content.title,
3434
}
3535
})
3636
}
3737
38-
async function editContentFile(id: string) {
39-
const fsPath = host.document.getFileSystemPath(id)
38+
async function editContentFile(fsPath: string) {
4039
await context.activeTree.value.selectItemByFsPath(fsPath)
4140
ui.open()
4241
}
@@ -140,7 +139,7 @@ router.beforeEach((to, from) => {
140139
variant="outline"
141140
class="bg-transparent backdrop-blur-md px-2"
142141
label="Edit this page"
143-
@click="editContentFile(activeDocuments[0].id)"
142+
@click="editContentFile(activeDocuments[0].fsPath)"
144143
/>
145144
</UFieldGroup>
146145
</div>

src/app/src/components/content/ContentCard.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const props = defineProps({
2121
})
2222
2323
const itemExtensionIcon = computed(() => getFileIcon(props.item.fsPath))
24-
const collectionName = computed(() => props.item.collections[0])
25-
const isDirectory = computed(() => props.item.type === 'directory')
2624
</script>
2725

2826
<template>
@@ -58,13 +56,5 @@ const isDirectory = computed(() => props.item.type === 'directory')
5856
class="bg-elevated"
5957
/>
6058
</template>
61-
<template #bottom-right>
62-
<UBadge
63-
v-if="!isDirectory"
64-
:label="collectionName"
65-
size="xs"
66-
variant="soft"
67-
/>
68-
</template>
6959
</ItemCard>
7060
</template>

src/app/src/components/content/ContentEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const document = computed<DatabasePageItem>({
5050
return
5151
}
5252
53-
context.activeTree.value.draft.update(props.draftItem.id, {
53+
context.activeTree.value.draft.update(props.draftItem.fsPath, {
5454
...toRaw(document.value as DatabasePageItem),
5555
...toRaw(value),
5656
})

src/app/src/components/shared/item/ItemActionsDropdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const actions = computed<DropdownMenuItem[]>(() => {
4040
const hasPendingAction = pendingAction.value !== null
4141
const hasLoadingAction = loadingAction.value !== null
4242
43-
return computeItemActions(context.itemActions.value, props.item).map((action) => {
43+
return computeItemActions(context.itemActions.value, props.item, context.currentFeature.value).map((action) => {
4444
const isOneStepAction = oneStepActions.includes(action.id)
4545
const isPending = pendingAction.value?.id === action.id
4646
const isLoading = loadingAction.value?.id === action.id

src/app/src/components/shared/item/ItemActionsToolbar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const actions = computed(() => {
2424
const hasPendingAction = pendingAction.value !== null
2525
const hasLoadingAction = loadingAction.value !== null
2626
27-
return computeItemActions(context.itemActions.value, item.value).map((action) => {
27+
return computeItemActions(context.itemActions.value, item.value, context.currentFeature.value).map((action) => {
2828
const isOneStepAction = oneStepActions.includes(action.id)
2929
const isPending = pendingAction.value?.id === action.id
3030
const isLoading = loadingAction.value?.id === action.id

src/app/src/components/shared/item/ItemCard.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ const statusRingColor = computed(() => props.item.status && props.item.status !=
2222
const displayInfo = computed(() => {
2323
if (isDirectory.value) {
2424
const itemcount = props.item.children?.filter(child => !child.hide).length || 0
25-
const collectionCount = props.item.collections.length
26-
return `${itemcount} ${itemcount === 1 ? 'item' : 'items'} from ${collectionCount} ${collectionCount === 1 ? 'collection' : 'collections'}`
25+
return `${itemcount} ${itemcount === 1 ? 'item' : 'items'}`
2726
}
2827
return props.item.routePath || props.item.fsPath
2928
})
@@ -70,9 +69,8 @@ const displayInfo = computed(() => {
7069
</div>
7170
</div>
7271

73-
<div class="flex flex-col items-end justify-between self-stretch">
72+
<div class="flex items-end">
7473
<ItemActionsDropdown :item="item" />
75-
<slot name="bottom-right" />
7674
</div>
7775
</div>
7876
</UTooltip>

src/app/src/components/shared/item/ItemCardReview.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
import type { DraftItem } from '../../../types'
33
import type { PropType } from 'vue'
44
import { computed } from 'vue'
5-
import { DraftStatus, TreeRootId } from '../../../types'
5+
import { DraftStatus } from '../../../types'
66
import { getFileIcon } from '../../../utils/file'
77
import { COLOR_UI_STATUS_MAP } from '../../../utils/tree'
8-
import { useStudio } from '../../../composables/useStudio'
9-
10-
const { host } = useStudio()
118
129
const props = defineProps({
1310
draftItem: {
@@ -28,9 +25,7 @@ const originalPath = computed(() => {
2825
return null
2926
}
3027
31-
const isMedia = props.draftItem.original.id.startsWith(TreeRootId.Media)
32-
const hostApi = isMedia ? host.media : host.document
33-
return hostApi.getFileSystemPath(props.draftItem.original.id)
28+
return props.draftItem.original.fsPath
3429
})
3530
3631
function toggleOpen() {

0 commit comments

Comments
 (0)