Skip to content

Commit 9aa2a8d

Browse files
authored
feat(editor): form editor for YAML/JSON and frontmatter (#178)
1 parent 2b4ee9a commit 9aa2a8d

Some content is hidden

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

45 files changed

+2661
-121
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"zod": "^4.1.13"
9090
},
9191
"resolutions": {
92-
"@nuxt/content": "https://pkg.pr.new/@nuxt/content@c5cc00c",
92+
"@nuxt/content": "https://pkg.pr.new/@nuxt/content@9b4b4f2",
9393
"nuxt-component-meta": "^0.15.0",
9494
"@nuxt/ui": "https://pkg.pr.new/@nuxt/ui@049b182"
9595
},

playground/docus/app/pages/authors.vue

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,39 @@ const { data: authors } = await useAsyncData('authors-list', () => queryCollecti
88
<div>
99
<UContainer>
1010
<ContentRenderer :value="page" />
11+
<div class="flex flex-col gap-2">
12+
<UUser
13+
v-for="author in authors"
14+
:key="author.name"
15+
:name="author.name"
16+
:description="author.username ? `@${author.username}` : ''"
17+
:avatar="author.avatar"
18+
:to="author.to"
19+
>
20+
<template #name>
21+
<div class="flex gap-2">
22+
<span class="text-sm font-medium">{{ author.name }}</span>
23+
<span class="text-sm text-muted">
24+
- {{ author.username ? `@${author.username}` : '' }}
25+
</span>
26+
</div>
27+
</template>
1128

12-
<UUser
13-
v-for="author in authors"
14-
:key="author.name"
15-
:name="author.name"
16-
:description="author.username ? `@${author.username}` : ''"
17-
:avatar="author.avatar"
18-
:to="author.to"
19-
/>
29+
<template #description>
30+
<div class="flex gap-2">
31+
<UBadge
32+
v-for="module in author.modules"
33+
:key="module"
34+
variant="soft"
35+
size="xs"
36+
color="neutral"
37+
>
38+
{{ module }}
39+
</UBadge>
40+
</div>
41+
</template>
42+
</UUser>
43+
</div>
2044
</UContainer>
2145
</div>
2246
</template>

playground/docus/content.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const createAuthorsSchema = () => z.object({
1919
}),
2020
to: z.string(),
2121
username: z.string(),
22+
modules: z.array(z.string()),
2223
})
2324

2425
const collections: Record<string, DefinedCollection> = {

playground/docus/content/3.pages/authors.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,14 @@ pages: defineCollection({
2121

2222
## Authors list
2323

24-
Fetch from data collection:
24+
Fetch from data collection
25+
26+
```[content.config.ts]
27+
authors: defineCollection({
28+
type: 'data',
29+
source: {
30+
include: 'authors/**/*',
31+
},
32+
schema: createAuthorsSchema(),
33+
}),
34+
```

playground/docus/content/authors/atinux.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ avatar:
33
src: https://avatars.githubusercontent.com/u/904724?v=4
44
to: https://x.com/atinux
55
username: atinux
6+
modules:
7+
- hub
8+
- ui
9+
- auth

playground/docus/content/authors/farnabaz.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ avatar:
44
src: https://avatars.githubusercontent.com/u/2047945?v=4
55
to: https://x.com/farnabaz
66
username: farnabaz
7+
modules:
8+
- studio
9+
- content
10+
- mdc
11+
- hub
712
---
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Baptiste Leproux",
3+
"avatar": {
4+
"src": "https://avatars.githubusercontent.com/u/7290030?v=4"
5+
},
6+
"to": "https://x.com/_larbish",
7+
"username": "larbish",
8+
"modules": [
9+
"studio",
10+
"content",
11+
"supabase"
12+
]
13+
}

playground/docus/content/authors/larbish.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 23 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,27 @@ const language = computed(() => {
123123
class="flex-1"
124124
/>
125125
<template v-else>
126-
<ContentEditorTipTap
127-
v-if="preferences.editorMode === 'tiptap' && document.extension === ContentFileExtension.Markdown"
128-
v-model="document"
129-
:draft-item="draftItem"
130-
class="flex-1"
131-
/>
132126
<ContentEditorCode
133-
v-else
127+
v-if="preferences.editorMode === 'code'"
134128
v-model="document"
135129
:draft-item="draftItem"
136130
:read-only="readOnly"
137131
class="flex-1"
138132
/>
133+
<template v-else>
134+
<ContentEditorTipTap
135+
v-if="document.extension === ContentFileExtension.Markdown"
136+
v-model="document"
137+
:draft-item="draftItem"
138+
class="flex-1"
139+
/>
140+
<ContentEditorForm
141+
v-else
142+
v-model="document"
143+
:draft-item="draftItem"
144+
class="flex-1"
145+
/>
146+
</template>
139147
</template>
140148
</template>
141149
</div>

0 commit comments

Comments
 (0)