Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/[...puckPath]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export const dynamic = "force-static";
export async function generateMetadata({
params,
}: {
params: { puckPath: string[] };
params: Promise<{ puckPath: string[] }>;
}): Promise<Metadata> {
const { path } = resolvePuckPath(params.puckPath);
const { puckPath } = await params;
const { path } = resolvePuckPath(puckPath);
const pageRes = await getPageRes(path);
const data = pageRes?.data?.data;
const rootProps = data?.root.props || data?.root;
Expand Down Expand Up @@ -56,9 +57,10 @@ export async function generateMetadata({
export default async function Page({
params,
}: {
params: { puckPath: string[] };
params: Promise<{ puckPath: string[] }>;
}) {
const { path } = resolvePuckPath(params.puckPath);
const { puckPath } = await params;
const { path } = resolvePuckPath(puckPath);
const pageRes = await getPageRes(path);
const data = pageRes?.data?.data as Data;

Expand Down
10 changes: 6 additions & 4 deletions app/blog/[...puckPath]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export const dynamic = "force-static";
export async function generateMetadata({
params,
}: {
params: { puckPath: string[] };
params: Promise<{ puckPath: string[] }>;
}): Promise<Metadata> {
const blogPath = "/blog";
const { path } = resolvePuckPath(params.puckPath);
const { puckPath } = await params;
const { path } = resolvePuckPath(puckPath);
const pageRes = await getPageRes(`${blogPath}${path}`);
const data = pageRes?.data?.data;
const rootProps = data?.root?.props;
Expand Down Expand Up @@ -66,10 +67,11 @@ export async function generateMetadata({
export default async function Page({
params,
}: {
params: { puckPath: string[] };
params: Promise<{ puckPath: string[] }>;
}) {
const blogPath = "/blog";
const { path } = resolvePuckPath(params.puckPath);
const { puckPath } = await params;
const { path } = resolvePuckPath(puckPath);
const pageRes = await getPageRes(`${blogPath}${path}`);
const data = pageRes?.data?.data;

Expand Down
10 changes: 6 additions & 4 deletions app/edit/[[...puckPath]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import { getUserServer } from "../../../lib/get-user-server";
export async function generateMetadata({
params,
}: {
params: { puckPath: string[] };
params: Promise<{ puckPath: string[] }>;
}): Promise<Metadata> {
const { path } = resolvePuckPath(params.puckPath);
const { puckPath } = await params;
const { path } = resolvePuckPath(puckPath);

return {
title: `${path ? `Puck path ${path}` : "Puck"}`,
Expand All @@ -24,9 +25,10 @@ export async function generateMetadata({
export default async function Page({
params,
}: {
params: { puckPath: string[] };
params: Promise<{ puckPath: string[] }>;
}) {
const { path } = resolvePuckPath(params.puckPath);
const { puckPath } = await params;
const { path } = resolvePuckPath(puckPath);

const pageRes = await supabase
.from("puck")
Expand Down
7 changes: 5 additions & 2 deletions app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { createBrowserClient } from "@supabase/ssr";
import { Auth } from "@supabase/auth-ui-react";
import {
// Import predefined theme
Expand All @@ -10,7 +10,10 @@ import {
import { useEffect } from "react";
import { useUser } from "../../lib/use-user";

const supabase = createClientComponentClient();
const supabase = createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);

export default function Login() {
const user = useUser();
Expand Down
27 changes: 25 additions & 2 deletions lib/get-user-server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { cookies } from "next/headers";
import { createServerComponentClient } from "@supabase/auth-helpers-nextjs";
import { createServerClient } from "@supabase/ssr";

export const getUserServer = async () => {
const supabase = createServerComponentClient({ cookies });
const cookieStore = await cookies();

const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
);
} catch {
// The `setAll` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
}
);

const userResponse = await supabase.auth.getUser();

Expand Down
7 changes: 5 additions & 2 deletions lib/use-user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { createBrowserClient } from "@supabase/ssr";
import { UserResponse } from "@supabase/supabase-js";
import { useEffect, useState } from "react";

export const useUser = () => {
const supabase = createClientComponentClient();
const supabase = createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);

const [user, setUser] = useState<UserResponse["data"]["user"] | undefined>();

Expand Down
21 changes: 19 additions & 2 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import { createMiddlewareClient } from "@supabase/auth-helpers-nextjs";
import { createServerClient } from "@supabase/ssr";
import { NextResponse } from "next/server";

import type { NextRequest } from "next/server";

export async function middleware(req: NextRequest) {
const res = NextResponse.next();
const supabase = createMiddlewareClient({ req, res });

const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return req.cookies.getAll();
},
setAll(cookiesToSet) {
cookiesToSet.forEach(({ name, value, options }) => {
req.cookies.set(name, value);
res.cookies.set(name, value, options);
});
},
},
}
);

await supabase.auth.getSession();

Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
"version": "0.0.2",
"private": true,
"dependencies": {
"@measured/puck": "0.17.0-canary.5e57623",
"@measured/puck-plugin-heading-analyzer": "0.17.0-canary.5e57623",
"@supabase/auth-helpers-nextjs": "^0.10.0",
"@measured/puck": "^0.19.1",
"@measured/puck-plugin-heading-analyzer": "^0.19.1",
"@supabase/auth-ui-react": "^0.4.6",
"@supabase/auth-ui-shared": "^0.1.6",
"@supabase/ssr": "^0.5.2",
"@supabase/supabase-js": "^2.39.0",
"classnames": "^2.5.1",
"deepmerge": "^4.3.1",
"feed": "^4.2.2",
"next": "^14.2.22",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"next": "^15.1.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rehype-color-chips": "^0.1.3",
"rehype-highlight": "^7.0.0",
"rehype-sanitize": "^6.0.0",
Expand All @@ -27,8 +27,8 @@
},
"devDependencies": {
"@types/node": "^22.10.5",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@typescript-eslint/typescript-estree": "^8.18.1",
"encoding": "^0.1.13",
"eslint": "8.57.0",
Expand Down
23 changes: 14 additions & 9 deletions puck/components/Grid.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentConfig } from "@measured/puck";
import { ReactNode } from "react";

import {
Grid as _Grid,
Expand Down Expand Up @@ -26,11 +27,13 @@ export const Grid: ComponentConfig<GridProps> = {
},
render: ({ gap, puck: { renderDropZone } }) => (
<_Grid gap={gap}>
{renderDropZone({
className: gridClassName(gap),
allow: ["GridItem"],
zone: "grid",
})}
{
renderDropZone({
className: gridClassName(gap),
allow: ["GridItem"],
zone: "grid",
}) as ReactNode
}
</_Grid>
),
};
Expand Down Expand Up @@ -124,10 +127,12 @@ export const GridItem: ComponentConfig<GridItemProps> = {
rowStart={rowStart}
ref={dragRef}
>
{renderDropZone({
disallow: ["Grid", "GridItem", "Section"],
zone: "grid-item",
})}
{
renderDropZone({
disallow: ["Grid", "GridItem", "Section"],
zone: "grid-item",
}) as ReactNode
}
</_Grid.Item>
),
};
5 changes: 4 additions & 1 deletion puck/components/Section.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentConfig } from "@measured/puck";
import { ReactNode } from "react";

import {
Section as _Section,
Expand All @@ -21,6 +22,8 @@ export const Section: ComponentConfig<SectionProps> = {
},
},
render: ({ width, puck: { renderDropZone } }) => (
<_Section width={width}>{renderDropZone({ zone: "section" })}</_Section>
<_Section width={width}>
{renderDropZone({ zone: "section" }) as ReactNode}
</_Section>
),
};
3 changes: 2 additions & 1 deletion puck/config.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Config, Data, DefaultRootProps } from "@measured/puck";
import { ReactNode } from "react";

import { Page } from "../components";

Expand Down Expand Up @@ -162,7 +163,7 @@ export const config: Config<Props, RootProps> = {
{renderDropZone({
disallow: ["GridItem"],
zone: "default-zone",
})}
}) as ReactNode}
</Page>
);
},
Expand Down
Loading