fix: homepage
This commit is contained in:
parent
3148231cc8
commit
ee0fa3678f
7 changed files with 18186 additions and 9 deletions
|
|
@ -9,12 +9,12 @@ import { RefreshRouteOnSave } from '@/components/RefreshRouteOnSave/RefreshRoute
|
|||
import { draftMode } from 'next/headers'
|
||||
|
||||
type Props = {
|
||||
params: Promise<{ slug: string }>
|
||||
params: Promise<{ slug?: string }>
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const slug = (await params).slug
|
||||
const page = await fetchPageBySlug(slug)
|
||||
const page = await fetchPageBySlug(slug || "")
|
||||
|
||||
if (!page) return {}
|
||||
|
||||
|
|
@ -27,15 +27,15 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|||
export default async function DynamicPage({ params }: Props) {
|
||||
const slug = (await params).slug
|
||||
const { isEnabled: isDraft } = await draftMode()
|
||||
const page = await fetchPageBySlug(slug, isDraft)
|
||||
const page = await fetchPageBySlug(slug || "", isDraft)
|
||||
const authenticated = await isAuthenticated()
|
||||
|
||||
if (!page) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
if(!authenticated && page._status !== "published") {
|
||||
notFound();
|
||||
if (!authenticated && page._status !== 'published') {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const firstBlockType = page.content?.[0]?.blockType
|
||||
|
|
@ -52,7 +52,7 @@ export default async function DynamicPage({ params }: Props) {
|
|||
)}
|
||||
|
||||
<AdminMenu
|
||||
collection={"pages"}
|
||||
collection={'pages'}
|
||||
id={page.id}
|
||||
isAuthenticated={authenticated}
|
||||
/>
|
||||
|
|
@ -51,7 +51,8 @@ export const Pages: CollectionConfig = {
|
|||
{
|
||||
name: 'slug',
|
||||
type: 'text',
|
||||
required: true,
|
||||
defaultValue: '',
|
||||
required: false,
|
||||
unique: true,
|
||||
label: {
|
||||
de: 'Slug',
|
||||
|
|
|
|||
18151
src/migrations/20260408_115618.json
Normal file
18151
src/migrations/20260408_115618.json
Normal file
File diff suppressed because it is too large
Load diff
19
src/migrations/20260408_115618.ts
Normal file
19
src/migrations/20260408_115618.ts
Normal 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;`)
|
||||
}
|
||||
|
|
@ -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_223804_contactperson_block from './20260319_223804_contactperson_block';
|
||||
import * as migration_20260319_224419 from './20260319_224419';
|
||||
import * as migration_20260408_115618 from './20260408_115618';
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
|
|
@ -154,6 +155,11 @@ export const migrations = [
|
|||
{
|
||||
up: migration_20260319_224419.up,
|
||||
down: migration_20260319_224419.down,
|
||||
name: '20260319_224419'
|
||||
name: '20260319_224419',
|
||||
},
|
||||
{
|
||||
up: migration_20260408_115618.up,
|
||||
down: migration_20260408_115618.down,
|
||||
name: '20260408_115618'
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ export interface Page {
|
|||
/**
|
||||
* URL-Pfad der Seite (z.B. "meine-seite" → /meine-seite)
|
||||
*/
|
||||
slug: string;
|
||||
slug?: string | null;
|
||||
content?:
|
||||
| (
|
||||
| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue