fix: homepage

This commit is contained in:
Benno Tielen 2026-04-08 14:12:38 +02:00
parent 3148231cc8
commit ee0fa3678f
7 changed files with 18186 additions and 9 deletions

View file

@ -9,12 +9,12 @@ import { RefreshRouteOnSave } from '@/components/RefreshRouteOnSave/RefreshRoute
import { draftMode } from 'next/headers' import { draftMode } from 'next/headers'
type Props = { type Props = {
params: Promise<{ slug: string }> params: Promise<{ slug?: string }>
} }
export async function generateMetadata({ params }: Props): Promise<Metadata> { export async function generateMetadata({ params }: Props): Promise<Metadata> {
const slug = (await params).slug const slug = (await params).slug
const page = await fetchPageBySlug(slug) const page = await fetchPageBySlug(slug || "")
if (!page) return {} if (!page) return {}
@ -27,15 +27,15 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
export default async function DynamicPage({ params }: Props) { export default async function DynamicPage({ params }: Props) {
const slug = (await params).slug const slug = (await params).slug
const { isEnabled: isDraft } = await draftMode() const { isEnabled: isDraft } = await draftMode()
const page = await fetchPageBySlug(slug, isDraft) const page = await fetchPageBySlug(slug || "", isDraft)
const authenticated = await isAuthenticated() const authenticated = await isAuthenticated()
if (!page) { if (!page) {
notFound() notFound()
} }
if(!authenticated && page._status !== "published") { if (!authenticated && page._status !== 'published') {
notFound(); notFound()
} }
const firstBlockType = page.content?.[0]?.blockType const firstBlockType = page.content?.[0]?.blockType
@ -52,7 +52,7 @@ export default async function DynamicPage({ params }: Props) {
)} )}
<AdminMenu <AdminMenu
collection={"pages"} collection={'pages'}
id={page.id} id={page.id}
isAuthenticated={authenticated} isAuthenticated={authenticated}
/> />

View file

@ -51,7 +51,8 @@ export const Pages: CollectionConfig = {
{ {
name: 'slug', name: 'slug',
type: 'text', type: 'text',
required: true, defaultValue: '',
required: false,
unique: true, unique: true,
label: { label: {
de: 'Slug', de: 'Slug',

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-04-12T11:56:17.764Z';
ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-04-12T11:56:18.063Z';
ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-05-08T11:56:18.128Z';
ALTER TABLE "pages" ALTER COLUMN "slug" SET DEFAULT '';
ALTER TABLE "_pages_v" ALTER COLUMN "version_slug" SET DEFAULT '';`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-03-22T22:44:18.451Z';
ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-03-22T22:44:18.743Z';
ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-04-18T21:44:18.801Z';
ALTER TABLE "pages" ALTER COLUMN "slug" DROP DEFAULT;
ALTER TABLE "_pages_v" ALTER COLUMN "version_slug" DROP DEFAULT;`)
}

View file

@ -24,6 +24,7 @@ import * as migration_20260311_110236_live_preview from './20260311_110236_live_
import * as migration_20260319_215840_collaps_item from './20260319_215840_collaps_item'; import * as migration_20260319_215840_collaps_item from './20260319_215840_collaps_item';
import * as migration_20260319_223804_contactperson_block from './20260319_223804_contactperson_block'; import * as migration_20260319_223804_contactperson_block from './20260319_223804_contactperson_block';
import * as migration_20260319_224419 from './20260319_224419'; import * as migration_20260319_224419 from './20260319_224419';
import * as migration_20260408_115618 from './20260408_115618';
export const migrations = [ export const migrations = [
{ {
@ -154,6 +155,11 @@ export const migrations = [
{ {
up: migration_20260319_224419.up, up: migration_20260319_224419.up,
down: migration_20260319_224419.down, down: migration_20260319_224419.down,
name: '20260319_224419' name: '20260319_224419',
},
{
up: migration_20260408_115618.up,
down: migration_20260408_115618.down,
name: '20260408_115618'
}, },
]; ];

View file

@ -716,7 +716,7 @@ export interface Page {
/** /**
* URL-Pfad der Seite (z.B. "meine-seite" /meine-seite) * URL-Pfad der Seite (z.B. "meine-seite" /meine-seite)
*/ */
slug: string; slug?: string | null;
content?: content?:
| ( | (
| { | {