feat: editor tags input

This commit is contained in:
DIYgod 2022-08-17 21:31:41 +01:00
parent 8eb2dd66ab
commit 8c363ac925
No known key found for this signature in database
GPG Key ID: D159328F47A80DCA
2 changed files with 26 additions and 2 deletions

View File

@ -42,6 +42,7 @@ export async function createOrUpdatePage(input: {
pageId?: string
siteId: string
slug?: string
tags?: string
title?: string
content?: string
published?: boolean
@ -77,7 +78,13 @@ export async function createOrUpdatePage(input: {
mime_type: "text/markdown",
},
}),
tags: [input.isPost ? "post" : "page"],
tags: [
input.isPost ? "post" : "page",
...(input.tags
?.split(",")
.map((tag) => tag.trim())
.filter((tag) => tag) || []),
],
applications: ["xlog"],
...(input.slug && {
attributes: [

View File

@ -59,6 +59,7 @@ export default function SubdomainEditor() {
published: false,
excerpt: "",
slug: "",
tags: "",
})
const [content, setContent] = useState("")
@ -149,6 +150,10 @@ export default function SubdomainEditor() {
page.data.date_published !== new Date("9999-01-01").toISOString(),
excerpt: page.data.summary?.content || "",
slug: page.data.slug!,
tags:
page.data.tags
?.filter((tag) => tag !== "post" && tag !== "page")
?.join(", ") || "",
})
}, [page.data])
@ -242,7 +247,6 @@ export default function SubdomainEditor() {
label="Page slug"
id="slug"
isBlock
placeholder="some-slug"
onChange={(e: ChangeEvent<HTMLInputElement>) =>
updateValue("slug", e.target.value)
}
@ -266,6 +270,19 @@ export default function SubdomainEditor() {
}
/>
</div>
<div>
<Input
name="tags"
value={values.tags}
label="Tags"
id="tags"
isBlock
onChange={(e: ChangeEvent<HTMLInputElement>) =>
updateValue("tags", e.target.value)
}
help="Separate multiple tags with commas"
/>
</div>
<div>
<Input
label="Excerpt"