diff --git a/actions/createNewLeaflet.ts b/actions/createNewLeaflet.ts
index 934999df..ec825f78 100644
--- a/actions/createNewLeaflet.ts
+++ b/actions/createNewLeaflet.ts
@@ -17,10 +17,15 @@ import { v7 } from "uuid";
import { sql, eq, and } from "drizzle-orm";
import { cookies } from "next/headers";
-export async function createNewLeaflet(
- pageType: "canvas" | "doc",
- redirectUser: boolean,
-) {
+export async function createNewLeaflet({
+ pageType,
+ redirectUser,
+ firstBlockType,
+}: {
+ pageType: "canvas" | "doc";
+ redirectUser: boolean;
+ firstBlockType?: "h1" | "text";
+}) {
const client = postgres(process.env.DB_URL as string, { idle_timeout: 5 });
let auth_token = (await cookies()).get("auth_token")?.value;
const db = drizzle(client);
@@ -107,18 +112,29 @@ export async function createNewLeaflet(
attribute: "card/block",
data: sql`${{ type: "ordered-reference", value: blockEntity.id, position: "a0" }}::jsonb`,
},
- {
- id: v7(),
- entity: blockEntity.id,
- attribute: "block/type",
- data: sql`${{ type: "block-type-union", value: "heading" }}::jsonb`,
- },
- {
- id: v7(),
- entity: blockEntity.id,
- attribute: "block/heading-level",
- data: sql`${{ type: "number", value: 1 }}::jsonb`,
- },
+ ...(firstBlockType === "text"
+ ? [
+ {
+ id: v7(),
+ entity: blockEntity.id,
+ attribute: "block/type",
+ data: sql`${{ type: "block-type-union", value: "text" }}::jsonb`,
+ },
+ ]
+ : [
+ {
+ id: v7(),
+ entity: blockEntity.id,
+ attribute: "block/type",
+ data: sql`${{ type: "block-type-union", value: "heading" }}::jsonb`,
+ },
+ {
+ id: v7(),
+ entity: blockEntity.id,
+ attribute: "block/heading-level",
+ data: sql`${{ type: "number", value: 1 }}::jsonb`,
+ },
+ ]),
]);
}
if (auth_token) {
diff --git a/actions/createPublicationDraft.ts b/actions/createPublicationDraft.ts
index bd640fcf..d8ffbfa2 100644
--- a/actions/createPublicationDraft.ts
+++ b/actions/createPublicationDraft.ts
@@ -6,7 +6,11 @@ import { supabaseServerClient } from "supabase/serverClient";
export async function createPublicationDraft(publication_uri: string) {
let identity = await getIdentityData();
if (!identity || !identity.atp_did) return null;
- let newLeaflet = await createNewLeaflet("doc", false);
+ let newLeaflet = await createNewLeaflet({
+ pageType: "doc",
+ redirectUser: false,
+ firstBlockType: "text",
+ });
console.log(
await supabaseServerClient
.from("leaflets_in_publications")
diff --git a/app/home/CreateNewButton.tsx b/app/home/CreateNewButton.tsx
index f5f72bd9..58605c0e 100644
--- a/app/home/CreateNewButton.tsx
+++ b/app/home/CreateNewButton.tsx
@@ -62,7 +62,10 @@ export const CreateNewLeafletButton = (props: {}) => {
>