feat: portfolio editor
This commit is contained in:
parent
16b4c56eee
commit
d644b14cf8
|
|
@ -1,5 +1,16 @@
|
|||
import PageComponent from "./page-component"
|
||||
import PortfolioEditor from "./portfolio-editor"
|
||||
import PostEditor from "./post-editor"
|
||||
|
||||
export default function SubdomainEditor() {
|
||||
return <PageComponent />
|
||||
export default function SubdomainEditor({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams?: {
|
||||
type: string
|
||||
}
|
||||
}) {
|
||||
if (searchParams?.type === "portfolio") {
|
||||
return <PortfolioEditor />
|
||||
} else {
|
||||
return <PostEditor />
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ const DynamicPageContent = dynamic(
|
|||
},
|
||||
)
|
||||
|
||||
export default function SubdomainEditor() {
|
||||
export default function PostEditor() {
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation("dashboard")
|
||||
|
|
@ -940,7 +940,7 @@ const EditorAdvancedModal: FC<{
|
|||
{t("Publish at")}
|
||||
</label>
|
||||
<DateInput
|
||||
className="[&_input]:bg-slate-50 [&_input]:text-black/90"
|
||||
className="[&_input]:text-black/90"
|
||||
allowDeselect
|
||||
clearable
|
||||
valueFormat="YYYY-MM-DD, h:mm a"
|
||||
|
|
@ -104,7 +104,7 @@ export default function DashboardLayout({
|
|||
{
|
||||
isActive: ({ href, pathname }) => href === pathname,
|
||||
icon: "icon-[mingcute--add-circle-line]",
|
||||
text: "Creation",
|
||||
text: "Publishing",
|
||||
},
|
||||
{
|
||||
href: `/dashboard/${subdomain}/posts`,
|
||||
|
|
@ -120,6 +120,13 @@ export default function DashboardLayout({
|
|||
text: "Pages",
|
||||
lever: 2,
|
||||
},
|
||||
{
|
||||
href: `/dashboard/${subdomain}/portfolios`,
|
||||
isActive: ({ href, pathname }) => href === pathname,
|
||||
icon: "icon-[mingcute--cloud-line]",
|
||||
text: "Portfolios",
|
||||
lever: 2,
|
||||
},
|
||||
{
|
||||
href: `/dashboard/${subdomain}/import`,
|
||||
isActive: ({ pathname }) =>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
import { PagesManager } from "~/components/dashboard/PagesManager"
|
||||
|
||||
export default function SubdomainPages() {
|
||||
return <PagesManager type="portfolio" />
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ export const initialEditorState = {
|
|||
mime_type: "",
|
||||
},
|
||||
disableAISummary: false,
|
||||
externalUrl: "",
|
||||
}
|
||||
export type Values = {
|
||||
title: string
|
||||
|
|
@ -27,6 +28,7 @@ export type Values = {
|
|||
mime_type?: string
|
||||
}
|
||||
disableAISummary: boolean
|
||||
externalUrl: string
|
||||
}
|
||||
|
||||
export const useEditorState = create<
|
||||
|
|
|
|||
|
|
@ -32,12 +32,10 @@ export const expandCrossbellNote = async ({
|
|||
)
|
||||
|
||||
if (expandedNote.metadata?.content) {
|
||||
let rendered
|
||||
if (expandedNote.metadata?.content?.content) {
|
||||
const { renderPageContent } = await import("~/markdown")
|
||||
const rendered = renderPageContent(
|
||||
expandedNote.metadata.content.content,
|
||||
true,
|
||||
)
|
||||
rendered = renderPageContent(expandedNote.metadata.content.content, true)
|
||||
if (keyword) {
|
||||
const position = expandedNote.metadata.content.content
|
||||
.toLowerCase()
|
||||
|
|
@ -51,23 +49,6 @@ export const expandCrossbellNote = async ({
|
|||
expandedNote.metadata.content.summary = rendered.excerpt
|
||||
}
|
||||
}
|
||||
expandedNote.metadata.content.cover =
|
||||
expandedNote.metadata?.content?.attachments?.find(
|
||||
(attachment) => attachment.name === "cover",
|
||||
)?.address || rendered.cover
|
||||
|
||||
expandedNote.metadata.content.images = []
|
||||
const cover = expandedNote.metadata?.content?.attachments?.find(
|
||||
(attachment) => attachment.name === "cover",
|
||||
)?.address
|
||||
if (cover) {
|
||||
expandedNote.metadata.content.images.push(cover)
|
||||
}
|
||||
expandedNote.metadata.content.images =
|
||||
expandedNote.metadata.content.images.concat(rendered.images)
|
||||
expandedNote.metadata.content.images = [
|
||||
...new Set(expandedNote.metadata.content.images),
|
||||
]
|
||||
|
||||
expandedNote.metadata.content.audio = rendered.audio
|
||||
expandedNote.metadata.content.frontMatter = rendered.frontMatter
|
||||
|
|
@ -76,6 +57,24 @@ export const expandCrossbellNote = async ({
|
|||
expandedNote.metadata.content.contentHTML = rendered.contentHTML
|
||||
}
|
||||
}
|
||||
expandedNote.metadata.content.cover =
|
||||
expandedNote.metadata?.content?.attachments?.find(
|
||||
(attachment) => attachment.name === "cover",
|
||||
)?.address || rendered?.cover
|
||||
|
||||
expandedNote.metadata.content.images = []
|
||||
const cover = expandedNote.metadata?.content?.attachments?.find(
|
||||
(attachment) => attachment.name === "cover",
|
||||
)?.address
|
||||
if (cover) {
|
||||
expandedNote.metadata.content.images.push(cover)
|
||||
}
|
||||
expandedNote.metadata.content.images =
|
||||
expandedNote.metadata.content.images.concat(rendered?.images || [])
|
||||
expandedNote.metadata.content.images = [
|
||||
...new Set(expandedNote.metadata.content.images),
|
||||
]
|
||||
|
||||
expandedNote.metadata.content.slug = getNoteSlug(expandedNote)
|
||||
if (!expandedNote.metadata.content.date_published && expandedNote.noteId) {
|
||||
expandedNote.metadata.content.date_published = expandedNote.createdAt
|
||||
|
|
|
|||
|
|
@ -221,5 +221,6 @@
|
|||
"Disable AI-generated summary": "禁用 AI 生成的摘要",
|
||||
"Pin": "置顶",
|
||||
"Unpin": "取消置顶",
|
||||
"Interaction": "互动"
|
||||
"Interaction": "互动",
|
||||
"External Url": "外部链接"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ const getLocalPages = (input: {
|
|||
date_published: page.values?.publishedAt,
|
||||
summary: page.values?.excerpt,
|
||||
tags: [
|
||||
input.type,
|
||||
page.type,
|
||||
...(page.values?.tags
|
||||
?.split(",")
|
||||
.map((tag: string) => tag.trim())
|
||||
|
|
@ -127,6 +127,22 @@ const getLocalPages = (input: {
|
|||
slug: page.values?.slug,
|
||||
sources: ["xlog"],
|
||||
disableAISummary: page.values?.disableAISummary,
|
||||
external_urls: page.values?.external_url
|
||||
? [page.values?.external_url]
|
||||
: undefined,
|
||||
cover: page.values?.cover?.address,
|
||||
images: [page.values?.cover?.address],
|
||||
attachments: [
|
||||
...(page.values?.cover?.address
|
||||
? [
|
||||
{
|
||||
name: "cover",
|
||||
address: page.values?.cover.address,
|
||||
mime_type: page.values?.cover.mime_type,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
},
|
||||
local: true,
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ export function useCreatePage() {
|
|||
mime_type?: string
|
||||
}
|
||||
disableAISummary?: boolean
|
||||
externalUrl?: string
|
||||
}) => {
|
||||
if (!input.characterId) {
|
||||
throw new Error("characterId is required")
|
||||
|
|
@ -273,6 +274,7 @@ export function useCreatePage() {
|
|||
]
|
||||
: []),
|
||||
],
|
||||
external_urls: [input.externalUrl],
|
||||
} as NoteMetadata & {
|
||||
summary?: string
|
||||
},
|
||||
|
|
@ -313,6 +315,7 @@ export function useUpdatePage() {
|
|||
mime_type?: string
|
||||
}
|
||||
disableAISummary?: boolean
|
||||
externalUrl?: string
|
||||
}) => {
|
||||
if (!input.characterId || !input.noteId) {
|
||||
throw new Error("characterId and noteId are required")
|
||||
|
|
@ -407,6 +410,13 @@ export function useUpdatePage() {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (input.externalUrl) {
|
||||
if (!metadataDraft.external_urls) {
|
||||
metadataDraft.external_urls = []
|
||||
}
|
||||
metadataDraft.external_urls[0] = input.externalUrl
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue