From 737c2b84110bcdcf05c239c38ecde5e0a845d931 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 9 Mar 2023 02:04:26 +0000 Subject: [PATCH] fix: import submit issue --- showcase.json | 4 +- src/lib/helpers.ts | 4 +- .../dashboard/[subdomain]/import/markdown.tsx | 73 ++++++++++--------- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/showcase.json b/showcase.json index 22e428f2..5390926a 100644 --- a/showcase.json +++ b/showcase.json @@ -11,7 +11,6 @@ "walter", "crossbell-io-updates", "xtao", - "polebug", "boyuand", "139", "kanikig", @@ -100,5 +99,6 @@ "tea-24", "revery", "hsinyau", - "rootless" + "rootless", + "haydenull" ] diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index a03dd9d3..c8f4c365 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -41,6 +41,8 @@ export const getDefaultSlug = (title: string, id?: string) => { ?.map((word) => word.trim()) ?.filter((word) => word) ?.join("-") - ?.replace(/\s+/g, "-") || id?.replace(`local-`, "") + ?.replace(/\s+/g, "-") || + id?.replace(`local-`, "") || + "" ) } diff --git a/src/pages/dashboard/[subdomain]/import/markdown.tsx b/src/pages/dashboard/[subdomain]/import/markdown.tsx index a44a97a8..fc6e215c 100644 --- a/src/pages/dashboard/[subdomain]/import/markdown.tsx +++ b/src/pages/dashboard/[subdomain]/import/markdown.tsx @@ -1,10 +1,9 @@ import { useRouter } from "next/router" import { DashboardLayout } from "~/components/dashboard/DashboardLayout" import { DashboardMain } from "~/components/dashboard/DashboardMain" -import { UniLink } from "~/components/ui/UniLink" import { ReactElement, useEffect, useState } from "react" -import { useGetSite, useGetStat } from "~/queries/site" -import { useTranslation, Trans } from "next-i18next" +import { useGetSite } from "~/queries/site" +import { useTranslation } from "next-i18next" import { getServerSideProps as getLayoutServerSideProps } from "~/components/dashboard/DashboardLayout.server" import { GetServerSideProps } from "next" import { serverSidePropsHandler } from "~/lib/server-side-props" @@ -12,7 +11,7 @@ import { useForm } from "react-hook-form" import { Input } from "~/components/ui/Input" import { Button } from "~/components/ui/Button" import { readFiles } from "~/lib/read-files" -import { getDefaultSlug, getSiteLink } from "~/lib/helpers" +import { getSiteLink } from "~/lib/helpers" import type { NoteMetadata } from "crossbell.js" import { ImportPreview } from "~/components/dashboard/ImportPreview" import { usePostNotes } from "~/queries/page" @@ -45,8 +44,7 @@ export default function ImportMarkdownPage() { const [notes, setNotes] = useState() - form.handleSubmit(async (values) => { - console.log(values) + const handleSubmit = form.handleSubmit(async (values) => { if (notes?.length && site.data?.username && site.data.metadata?.proof) { postNotes.mutate({ siteId: site.data.username, @@ -63,7 +61,7 @@ export default function ImportMarkdownPage() { return { title: file.title, content: file.content, - tags: ["post", "Imported from file", ...file.tags], + tags: ["post", ...file.tags], sources: ["xlog"], attributes: [ { @@ -81,7 +79,6 @@ export default function ImportMarkdownPage() { } }) setNotes(notes) - console.log(files, notes) }, }) @@ -94,35 +91,39 @@ export default function ImportMarkdownPage() { return ( -
- -
-
Preview
- {notes?.length ? ( - notes?.map((note) => ) - ) : ( -
No files chosen
- )} +
+
+ +
+
Preview
+ {notes?.length ? ( + notes?.map((note) => ( + + )) + ) : ( +
No files chosen
+ )} +
+
+ +
-
- -
-
+ ) }