mirror of
https://github.com/jordienr/zenblog.git
synced 2026-08-24 10:14:46 -05:00
fix next 16 route handler and params types
This commit is contained in:
@@ -8,21 +8,23 @@ import ReactSyntaxHighlighter from "react-syntax-highlighter";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
type Params = {
|
||||
params: {
|
||||
params: Promise<{
|
||||
slug: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
|
||||
export async function generateMetadata({ params }: Params) {
|
||||
const blog = getBlogClient();
|
||||
const { data: post } = await blog.posts.get({ slug: params.slug });
|
||||
const { slug } = await params;
|
||||
const { data: post } = await blog.posts.get({ slug });
|
||||
|
||||
return {
|
||||
title: post.title,
|
||||
description: post.excerpt,
|
||||
};
|
||||
}
|
||||
const Post = async ({ params: { slug } }: Params) => {
|
||||
const Post = async ({ params }: Params) => {
|
||||
const { slug } = await params;
|
||||
const blog = getBlogClient();
|
||||
const { data: post } = await blog.posts.get({ slug });
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { z } from "zod";
|
||||
import { logger } from "hono/logger";
|
||||
import { prettyJSON } from "hono/pretty-json";
|
||||
import { handle } from "hono/vercel";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { createClient } from "@/lib/server/supabase";
|
||||
import { axiom, AXIOM_DATASETS, getApiUsageForBlog } from "lib/axiom";
|
||||
import {
|
||||
@@ -907,9 +908,21 @@ const app = new Hono()
|
||||
|
||||
export type ManagementAPI = typeof app;
|
||||
|
||||
export const OPTIONS = handle(app);
|
||||
export const GET = handle(app);
|
||||
export const POST = handle(app);
|
||||
export const PUT = handle(app);
|
||||
export const PATCH = handle(app);
|
||||
export const DELETE = handle(app);
|
||||
class NextFetchEventLike {
|
||||
constructor(readonly request: Request) {}
|
||||
respondWith(_promise: Response | Promise<Response>) {}
|
||||
passThroughOnException() {}
|
||||
waitUntil(_promise: Promise<void>) {}
|
||||
}
|
||||
|
||||
const honoHandler = handle(app);
|
||||
|
||||
const routeHandler = (request: NextRequest) =>
|
||||
honoHandler(request, new NextFetchEventLike(request) as any);
|
||||
|
||||
export const OPTIONS = routeHandler;
|
||||
export const GET = routeHandler;
|
||||
export const POST = routeHandler;
|
||||
export const PUT = routeHandler;
|
||||
export const PATCH = routeHandler;
|
||||
export const DELETE = routeHandler;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { handle } from "hono/vercel";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { createClient } from "@/lib/server/supabase";
|
||||
import { logger } from "hono/logger";
|
||||
import { prettyJSON } from "hono/pretty-json";
|
||||
@@ -650,8 +651,20 @@ app.get(
|
||||
})
|
||||
);
|
||||
|
||||
export const GET = handle(app);
|
||||
export const POST = handle(app);
|
||||
export const PUT = handle(app);
|
||||
export const PATCH = handle(app);
|
||||
export const DELETE = handle(app);
|
||||
class NextFetchEventLike {
|
||||
constructor(readonly request: Request) {}
|
||||
respondWith(_promise: Response | Promise<Response>) {}
|
||||
passThroughOnException() {}
|
||||
waitUntil(_promise: Promise<void>) {}
|
||||
}
|
||||
|
||||
const honoHandler = handle(app);
|
||||
|
||||
const routeHandler = (request: NextRequest) =>
|
||||
honoHandler(request, new NextFetchEventLike(request) as any);
|
||||
|
||||
export const GET = routeHandler;
|
||||
export const POST = routeHandler;
|
||||
export const PUT = routeHandler;
|
||||
export const PATCH = routeHandler;
|
||||
export const DELETE = routeHandler;
|
||||
|
||||
@@ -9,10 +9,11 @@ import Link from "next/link";
|
||||
import React from "react";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { subdomain, slug },
|
||||
params,
|
||||
}: {
|
||||
params: { subdomain: string; slug: string };
|
||||
params: Promise<{ subdomain: string; slug: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { subdomain, slug } = await params;
|
||||
console.log(subdomain);
|
||||
const { data: blog } = await getBlog(subdomain);
|
||||
const post = await getPost(subdomain, slug);
|
||||
@@ -51,10 +52,11 @@ export async function generateMetadata({
|
||||
}
|
||||
|
||||
const Post = async ({
|
||||
params: { slug, subdomain },
|
||||
params,
|
||||
}: {
|
||||
params: { slug: string; subdomain: string };
|
||||
params: Promise<{ slug: string; subdomain: string }>;
|
||||
}) => {
|
||||
const { slug, subdomain } = await params;
|
||||
const { data: blog } = await getBlog(subdomain);
|
||||
const post = await getPost(subdomain, slug);
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ export default async function Layout({
|
||||
children,
|
||||
params,
|
||||
}: PropsWithChildren<{
|
||||
params: { subdomain: string };
|
||||
params: Promise<{ subdomain: string }>;
|
||||
}>) {
|
||||
const { subdomain } = params;
|
||||
const { subdomain } = await params;
|
||||
const { data: blog } = await getBlog(subdomain);
|
||||
|
||||
return (
|
||||
|
||||
@@ -5,10 +5,11 @@ import { BlogHomePage } from "../themes/blog-home";
|
||||
import { Theme } from "app/types";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { subdomain },
|
||||
params,
|
||||
}: {
|
||||
params: { subdomain: string };
|
||||
params: Promise<{ subdomain: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { subdomain } = await params;
|
||||
console.log(subdomain);
|
||||
const { data: blog } = await getBlog(subdomain);
|
||||
|
||||
@@ -29,10 +30,11 @@ export async function generateMetadata({
|
||||
}
|
||||
|
||||
async function HostedBlog({
|
||||
params: { subdomain },
|
||||
params,
|
||||
}: {
|
||||
params: { subdomain: string };
|
||||
params: Promise<{ subdomain: string }>;
|
||||
}) {
|
||||
const { subdomain } = await params;
|
||||
const { data: blog, error: blogError } = await getBlog(subdomain);
|
||||
const { data: posts, error: postsError } = await getPosts(
|
||||
subdomain,
|
||||
|
||||
Reference in New Issue
Block a user