Blog seite Fiexed

This commit is contained in:
michi 2025-09-11 00:00:17 +02:00
parent 4721b59b10
commit 9dfb001fc9
25 changed files with 131 additions and 60 deletions

View File

@ -12,11 +12,6 @@
],
"rootMainFiles": [],
"pages": {
"/": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/index.js"
],
"/_app": [
"static/chunks/webpack.js",
"static/chunks/main.js",
@ -26,6 +21,16 @@
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/_error.js"
],
"/admin": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/admin.js"
],
"/admin/blog": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/admin/blog.js"
]
},
"ampFirstPages": []

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1,18 @@
{}
{
"..\\node_modules\\@supabase\\auth-js\\dist\\module\\lib\\helpers.js -> @supabase/node-fetch": {
"id": "..\\node_modules\\@supabase\\auth-js\\dist\\module\\lib\\helpers.js -> @supabase/node-fetch",
"files": []
},
"..\\node_modules\\@supabase\\functions-js\\dist\\module\\helper.js -> @supabase/node-fetch": {
"id": "..\\node_modules\\@supabase\\functions-js\\dist\\module\\helper.js -> @supabase/node-fetch",
"files": []
},
"..\\node_modules\\@supabase\\realtime-js\\dist\\module\\RealtimeClient.js -> @supabase/node-fetch": {
"id": "..\\node_modules\\@supabase\\realtime-js\\dist\\module\\RealtimeClient.js -> @supabase/node-fetch",
"files": []
},
"..\\node_modules\\@supabase\\storage-js\\dist\\module\\lib\\helpers.js -> @supabase/node-fetch": {
"id": "..\\node_modules\\@supabase\\storage-js\\dist\\module\\lib\\helpers.js -> @supabase/node-fetch",
"files": []
}
}

View File

@ -1 +1 @@
self.__BUILD_MANIFEST={"polyfillFiles":["static/chunks/polyfills.js"],"devFiles":["static/chunks/react-refresh.js"],"ampDevFiles":[],"lowPriorityFiles":["static/development/_buildManifest.js","static/development/_ssgManifest.js"],"rootMainFiles":[],"pages":{"/":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/index.js"],"/_app":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/_app.js"],"/_error":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/_error.js"]},"ampFirstPages":[]}
self.__BUILD_MANIFEST={"polyfillFiles":["static/chunks/polyfills.js"],"devFiles":["static/chunks/react-refresh.js"],"ampDevFiles":[],"lowPriorityFiles":["static/development/_buildManifest.js","static/development/_ssgManifest.js"],"rootMainFiles":[],"pages":{"/_app":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/_app.js"],"/_error":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/_error.js"],"/admin":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/admin.js"],"/admin/blog":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/admin/blog.js"]},"ampFirstPages":[]}

View File

@ -1,6 +1,25 @@
{
"sortedMiddleware": [],
"middleware": {},
"sortedMiddleware": [
"/"
],
"middleware": {
"/": {
"files": [
"server/edge-runtime-webpack.js",
"server/middleware.js"
],
"name": "middleware",
"page": "/",
"matchers": [
{
"regexp": "^/.*$",
"originalSource": "/:path*"
}
],
"wasm": [],
"assets": []
}
},
"functions": {},
"version": 2
}

View File

@ -1 +1 @@
self.__REACT_LOADABLE_MANIFEST="{}"
self.__REACT_LOADABLE_MANIFEST="{\"..\\\\node_modules\\\\@supabase\\\\auth-js\\\\dist\\\\module\\\\lib\\\\helpers.js -> @supabase/node-fetch\":{\"id\":\"..\\\\node_modules\\\\@supabase\\\\auth-js\\\\dist\\\\module\\\\lib\\\\helpers.js -> @supabase/node-fetch\",\"files\":[]},\"..\\\\node_modules\\\\@supabase\\\\functions-js\\\\dist\\\\module\\\\helper.js -> @supabase/node-fetch\":{\"id\":\"..\\\\node_modules\\\\@supabase\\\\functions-js\\\\dist\\\\module\\\\helper.js -> @supabase/node-fetch\",\"files\":[]},\"..\\\\node_modules\\\\@supabase\\\\realtime-js\\\\dist\\\\module\\\\RealtimeClient.js -> @supabase/node-fetch\":{\"id\":\"..\\\\node_modules\\\\@supabase\\\\realtime-js\\\\dist\\\\module\\\\RealtimeClient.js -> @supabase/node-fetch\",\"files\":[]},\"..\\\\node_modules\\\\@supabase\\\\storage-js\\\\dist\\\\module\\\\lib\\\\helpers.js -> @supabase/node-fetch\":{\"id\":\"..\\\\node_modules\\\\@supabase\\\\storage-js\\\\dist\\\\module\\\\lib\\\\helpers.js -> @supabase/node-fetch\",\"files\":[]}}"

View File

@ -2,5 +2,8 @@
"/_app": "pages/_app.js",
"/_error": "pages/_error.js",
"/_document": "pages/_document.js",
"/": "pages/index.js"
"/": "pages/index.js",
"/admin": "pages/admin.js",
"/admin/blog": "pages/admin/blog.js",
"/api/update-blog": "pages/api/update-blog.js"
}

View File

@ -1 +1 @@
self.__BUILD_MANIFEST = {__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static\u002Fchunks\u002Fpages\u002Findex.js"],"/_error":["static\u002Fchunks\u002Fpages\u002F_error.js"],sortedPages:["\u002F","\u002F_app","\u002F_error"]};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()
self.__BUILD_MANIFEST = {__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/_error":["static\u002Fchunks\u002Fpages\u002F_error.js"],"/admin":["static\u002Fchunks\u002Fpages\u002Fadmin.js"],"/admin/blog":["static\u002Fchunks\u002Fpages\u002Fadmin\u002Fblog.js"],sortedPages:["\u002F_app","\u002F_error","\u002Fadmin","\u002Fadmin\u002Fblog"]};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()

File diff suppressed because one or more lines are too long

View File

@ -389,10 +389,9 @@ export default function BlogAdmin() {
{content.type === 'text' && activeContentIndex === index && (
<div className="border rounded-lg p-3 bg-gray-50">
<div className="text-xs font-medium text-gray-600 mb-2">Vorschau:</div>
<div className="prose prose-sm max-w-none">
<div className="prose prose-sm max-w-none whitespace-pre-wrap">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
className="whitespace-pre-wrap"
components={{
p: ({children}) => <p className="mb-4 whitespace-pre-wrap">{children}</p>,
code: ({node, inline, className, children, ...props}) => {

View File

@ -1,14 +1,18 @@
import { supabase } from '../../lib/supabase';
import { supabaseAdmin } from '../../lib/supabase';
export default async function handler(req, res) {
if (req.method !== 'DELETE') {
return res.status(405).json({ error: 'Method not allowed' });
}
const isAuthenticated = req.cookies.isAuthenticated === 'true';
if (!isAuthenticated) {
// Get user from supabase session
const { data: sessionData, error: authError } = await supabaseAdmin.auth.getUser(req.cookies['sb-access-token']);
if (authError || !sessionData?.user) {
return res.status(401).json({ error: 'Unauthorized' });
}
const user = sessionData.user;
const { id } = req.body;
@ -17,10 +21,11 @@ export default async function handler(req, res) {
}
try {
const { error } = await supabase
const { error } = await supabaseAdmin
.from('blog_entries')
.delete()
.eq('id', id);
.eq('id', id)
.eq('author_id', user.id);
if (error) {
console.error('Supabase Lösch-Fehler:', error);

View File

@ -6,30 +6,38 @@ export default async function handler(req, res) {
return res.status(405).json({ error: 'Method not allowed' });
}
try {
const data = req.body;
if (!Array.isArray(data)) {
console.log('Invalid data format - not an array');
return res.status(400).json({ error: 'Data must be an array' });
}
try {
// Get user from supabase session
const { data: sessionData, error: authError } = await supabaseAdmin.auth.getUser(req.cookies['sb-access-token']);
if (authError || !sessionData?.user) {
return res.status(401).json({ error: 'Unauthorized' });
}
const user = sessionData.user;
const results = [];
for (const entry of data) {
const content = Array.isArray(entry.content) ? entry.content : [];
const data = req.body;
const cleanEntry = {
title: entry.title || '',
date: entry.date || '',
description: entry.description || '',
slug: entry.slug || '',
image: entry.image || '',
content: content,
updated_at: new Date().toISOString()
};
if (!Array.isArray(data)) {
console.log('Invalid data format - not an array');
return res.status(400).json({ error: 'Data must be an array' });
}
const results = [];
const { data: result, error } = await supabaseAdmin
for (const entry of data) {
const content = Array.isArray(entry.content) ? entry.content : [];
const cleanEntry = {
title: entry.title || '',
date: entry.date || '',
description: entry.description || '',
slug: entry.slug || '',
image: entry.image || '',
content: content,
author_id: user.id,
updated_at: new Date().toISOString()
}; const { data: result, error } = await supabaseAdmin
.from('blog_entries')
.upsert(cleanEntry, {
onConflict: 'slug',

View File

@ -46,7 +46,6 @@ export default function BlogPost({ blog }) {
<div key={index} className="prose prose-lg max-w-none">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
className="text-gray-700 text-base sm:text-lg leading-relaxed px-2 sm:px-0"
components={{
h1: ({children}) => <h1 className="text-3xl font-bold mb-4 text-gray-900">{children}</h1>,
h2: ({children}) => <h2 className="text-2xl font-bold mb-3 text-gray-900">{children}</h2>,