Erste brauchbare Version

This commit is contained in:
timg
2026-08-31 19:55:41 +02:00
parent 080c4d0f39
commit 892a4d4747
35 changed files with 7103 additions and 219 deletions
+17
View File
@@ -0,0 +1,17 @@
@import "tailwindcss";
:root {
--background: #FFFFFF;
--foreground: #000000;
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
}
body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}
+36
View File
@@ -0,0 +1,36 @@
import { type ReactNode } from 'react';
import { type Metadata } from 'next';
import { getPreview } from '@/lib/preview';
import RefreshRouteOnSave from '@/components/RefreshRouteOnSave';
import EndPreview from '@/components/EndPreviewButton';
import '@/app/(app)/globals.css';
type Props = Readonly<{
children: ReactNode;
}>;
export const metadata: Metadata = {
title: {
default: '<Title>',
template: '%s | <Template>'
},
description: '<Description>',
keywords: [ '<Keyword>' ],
alternates: {
canonical: 'https://<domain>'
}
};
export default async function RootLayout({ children }: Props) {
const { isPreview } = await getPreview();
return (
<html lang="de" >
<body>
<RefreshRouteOnSave />
{children}
{isPreview && <EndPreview />}
</body>
</html>
);
}
+29
View File
@@ -0,0 +1,29 @@
import Link from 'next/link';
import { getPreview } from '@/lib/preview';
import config from '@payload-config';
import { getPayload } from 'payload';
export default async function Page() {
const { isPreview, where } = await getPreview();
const payload = await getPayload({ config });
const posts = await payload.find({
collection: 'posts',
where,
draft: isPreview
});
return (
<main className="flex flex-col">
{posts.docs.map((post) => (
<Link
key={post.id}
className="border border-1 border-primary p-4 m-4"
href={`/post/${post.slug}`}
>
{post.title}
</Link>
))}
</main>
);
}
+15
View File
@@ -0,0 +1,15 @@
import Link from 'next/link';
export default function Page() {
return (
<div className="min-h-screen flex flex-col justify-center items-center">
<p>Post nicht gefunden</p>
<Link
className="border border-1 border-primary"
href="/"
>
Zurück
</Link>
</div>
);
}
+48
View File
@@ -0,0 +1,48 @@
import { notFound } from 'next/navigation';
import Link from 'next/link';
import { getPreview } from '@/lib/preview';
import config from '@payload-config';
import { getPayload } from 'payload';
import { RichText } from '@payloadcms/richtext-lexical/react';
type Props = Readonly<{
params: Promise<{
slug: string;
}>;
}>;
export default async function Page({ params }: Props) {
const { isPreview, where } = await getPreview();
const { slug } = await params;
const payload = await getPayload({ config });
const result = await payload.find({
collection: 'posts',
where: {
...where,
slug: {
equals: slug
}
},
draft: isPreview,
limit: 1
});
const post = result.docs[0];
if (!post)
return notFound();
return (
<div className="m-4">
<Link
className="border border-1 border-primary"
href="/"
>
Zurück
</Link>
<h1 className="font-bold">{post.title}</h1>
<RichText data={post.content} />
</div>
);
}
+19
View File
@@ -0,0 +1,19 @@
import { type MetadataRoute } from 'next';
export default function robots(): MetadataRoute.Robots {
return {
rules: [
{
userAgent: '*',
allow: '/',
disallow: [
'/private/',
'/cdn-cgi/',
'/_next/'
]
}
],
sitemap: 'https://<domain>/sitemap.xml'
};
}
+30
View File
@@ -0,0 +1,30 @@
import { type MetadataRoute } from 'next';
type Route = MetadataRoute.Sitemap[number];
type Params = Readonly<{
path: string;
changeFrequency?: Route['changeFrequency'];
priority?: Route['priority'];
}>;
const baseURL = 'https://<domain>';
function buildRoute({ path, changeFrequency = 'yearly', priority = 0.0 }: Params) {
const route = {
url: `${baseURL}${path}`,
changeFrequency,
priority
} as Route;
return route;
}
export default function sitemap(): MetadataRoute.Sitemap {
return [
buildRoute({ path: '/', changeFrequency: 'monthly', priority: 1.0 })
];
}