Fix: Remove Payload imports from blog page
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🩺 Smoke Test (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🩺 Smoke Test (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { notFound, redirect } from "next/navigation";
|
import { notFound, redirect } from "next/navigation";
|
||||||
import { getPayloadHMR } from "@payloadcms/next/utilities";
|
|
||||||
import configPromise from "@payload-config";
|
|
||||||
import { getAllPosts } from "@/src/lib/posts";
|
import { getAllPosts } from "@/src/lib/posts";
|
||||||
import { BlogPostHeader } from "@/src/components/blog/BlogPostHeader";
|
import { BlogPostHeader } from "@/src/components/blog/BlogPostHeader";
|
||||||
import { Section } from "@/src/components/Section";
|
import { Section } from "@/src/components/Section";
|
||||||
@@ -11,7 +10,7 @@ import { BlogPostClient } from "@/src/components/BlogPostClient";
|
|||||||
import { TextSelectionShare } from "@/src/components/TextSelectionShare";
|
import { TextSelectionShare } from "@/src/components/TextSelectionShare";
|
||||||
import { BlogPostStickyBar } from "@/src/components/blog/BlogPostStickyBar";
|
import { BlogPostStickyBar } from "@/src/components/blog/BlogPostStickyBar";
|
||||||
import { MDXContent } from "@/src/components/MDXContent";
|
import { MDXContent } from "@/src/components/MDXContent";
|
||||||
import { PayloadRichText } from "@/src/components/PayloadRichText";
|
|
||||||
import { TableOfContents } from "@/src/components/TableOfContents";
|
import { TableOfContents } from "@/src/components/TableOfContents";
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
@@ -58,18 +57,6 @@ export default async function BlogPostPage({
|
|||||||
const post = allPosts.find((p) => p.slug === slug);
|
const post = allPosts.find((p) => p.slug === slug);
|
||||||
|
|
||||||
if (!post) {
|
if (!post) {
|
||||||
const payload = await getPayloadHMR({ config: configPromise });
|
|
||||||
const redirectDoc = await payload.find({
|
|
||||||
collection: "redirects",
|
|
||||||
where: {
|
|
||||||
from: { equals: slug },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (redirectDoc.docs.length > 0) {
|
|
||||||
redirect(`/blog/${redirectDoc.docs[0].to}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,11 +106,7 @@ export default async function BlogPostPage({
|
|||||||
|
|
||||||
<div className="article-content max-w-none">
|
<div className="article-content max-w-none">
|
||||||
<TableOfContents />
|
<TableOfContents />
|
||||||
{post.lexicalContent ? (
|
<MDXContent code={post.mdxContent || ""} />
|
||||||
<PayloadRichText data={post.lexicalContent} />
|
|
||||||
) : (
|
|
||||||
<MDXContent code={post.body.code} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</Reveal>
|
</Reveal>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
import { getPayload } from "payload";
|
|
||||||
import configPromise from "@payload-config";
|
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deep CMS Health Check
|
|
||||||
* Validates that Payload CMS can actually query the database.
|
|
||||||
* Used by post-deploy smoke tests to catch migration/schema issues.
|
|
||||||
*/
|
|
||||||
export async function GET() {
|
|
||||||
const checks: Record<string, string> = {};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const payload = await getPayload({ config: configPromise });
|
|
||||||
checks.init = "ok";
|
|
||||||
|
|
||||||
// Verify each collection can be queried (catches missing locale tables, broken migrations)
|
|
||||||
// Adjusted for mintel.me collections
|
|
||||||
const collections = ["posts", "projects", "media", "inquiries"] as const;
|
|
||||||
for (const collection of collections) {
|
|
||||||
try {
|
|
||||||
await payload.find({ collection, limit: 1 });
|
|
||||||
checks[collection] = "ok";
|
|
||||||
} catch (e: any) {
|
|
||||||
checks[collection] = `error: ${e.message?.substring(0, 100)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasErrors = Object.values(checks).some((v) => v.startsWith("error"));
|
|
||||||
return NextResponse.json(
|
|
||||||
{ status: hasErrors ? "degraded" : "ok", checks },
|
|
||||||
{ status: hasErrors ? 503 : 200 },
|
|
||||||
);
|
|
||||||
} catch (e: any) {
|
|
||||||
return NextResponse.json(
|
|
||||||
{ status: "error", message: e.message?.substring(0, 200), checks },
|
|
||||||
{ status: 503 },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user