slug problem fixed
This commit is contained in:
parent
00af25d9d6
commit
3e478b3574
@ -12,6 +12,11 @@
|
|||||||
],
|
],
|
||||||
"rootMainFiles": [],
|
"rootMainFiles": [],
|
||||||
"pages": {
|
"pages": {
|
||||||
|
"/": [
|
||||||
|
"static/chunks/webpack.js",
|
||||||
|
"static/chunks/main.js",
|
||||||
|
"static/chunks/pages/index.js"
|
||||||
|
],
|
||||||
"/_app": [
|
"/_app": [
|
||||||
"static/chunks/webpack.js",
|
"static/chunks/webpack.js",
|
||||||
"static/chunks/main.js",
|
"static/chunks/main.js",
|
||||||
@ -27,6 +32,11 @@
|
|||||||
"static/chunks/main.js",
|
"static/chunks/main.js",
|
||||||
"static/chunks/pages/admin.js"
|
"static/chunks/pages/admin.js"
|
||||||
],
|
],
|
||||||
|
"/admin/login": [
|
||||||
|
"static/chunks/webpack.js",
|
||||||
|
"static/chunks/main.js",
|
||||||
|
"static/chunks/pages/admin/login.js"
|
||||||
|
],
|
||||||
"/blog/[slug]": [
|
"/blog/[slug]": [
|
||||||
"static/chunks/webpack.js",
|
"static/chunks/webpack.js",
|
||||||
"static/chunks/main.js",
|
"static/chunks/main.js",
|
||||||
|
|||||||
BIN
.next/cache/webpack/client-development/1.pack.gz
vendored
BIN
.next/cache/webpack/client-development/1.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/client-development/6.pack.gz
vendored
BIN
.next/cache/webpack/client-development/6.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/client-development/7.pack.gz
vendored
BIN
.next/cache/webpack/client-development/7.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/client-development/8.pack.gz
vendored
BIN
.next/cache/webpack/client-development/8.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/client-development/9.pack.gz
vendored
BIN
.next/cache/webpack/client-development/9.pack.gz
vendored
Binary file not shown.
Binary file not shown.
BIN
.next/cache/webpack/server-development/1.pack.gz
vendored
BIN
.next/cache/webpack/server-development/1.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/10.pack.gz
vendored
BIN
.next/cache/webpack/server-development/10.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/2.pack.gz
vendored
BIN
.next/cache/webpack/server-development/2.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/3.pack.gz
vendored
BIN
.next/cache/webpack/server-development/3.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/4.pack.gz
vendored
BIN
.next/cache/webpack/server-development/4.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/5.pack.gz
vendored
BIN
.next/cache/webpack/server-development/5.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/7.pack.gz
vendored
BIN
.next/cache/webpack/server-development/7.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/8.pack.gz
vendored
BIN
.next/cache/webpack/server-development/8.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/9.pack.gz
vendored
BIN
.next/cache/webpack/server-development/9.pack.gz
vendored
Binary file not shown.
BIN
.next/cache/webpack/server-development/index.pack.gz
vendored
BIN
.next/cache/webpack/server-development/index.pack.gz
vendored
Binary file not shown.
Binary file not shown.
@ -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":{"/_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"],"/blog/[slug]":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/blog/[slug].js"],"/devlog":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/devlog.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":{"/":["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"],"/admin":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/admin.js"],"/admin/login":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/admin/login.js"],"/blog/[slug]":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/blog/[slug].js"],"/devlog":["static/chunks/webpack.js","static/chunks/main.js","static/chunks/pages/devlog.js"]},"ampFirstPages":[]}
|
||||||
@ -4,5 +4,8 @@
|
|||||||
"/_document": "pages/_document.js",
|
"/_document": "pages/_document.js",
|
||||||
"/admin": "pages/admin.js",
|
"/admin": "pages/admin.js",
|
||||||
"/devlog": "pages/devlog.js",
|
"/devlog": "pages/devlog.js",
|
||||||
"/blog/[slug]": "pages/blog/[slug].js"
|
"/blog/[slug]": "pages/blog/[slug].js",
|
||||||
|
"/admin/login": "pages/admin/login.js",
|
||||||
|
"/api/logout": "pages/api/logout.js",
|
||||||
|
"/": "pages/index.js"
|
||||||
}
|
}
|
||||||
@ -1 +1 @@
|
|||||||
self.__BUILD_MANIFEST = {__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/_error":["static\u002Fchunks\u002Fpages\u002F_error.js"],"/admin":["static\u002Fchunks\u002Fpages\u002Fadmin.js"],"/blog/[slug]":["static\u002Fchunks\u002Fpages\u002Fblog\u002F[slug].js"],"/devlog":["static\u002Fchunks\u002Fpages\u002Fdevlog.js"],sortedPages:["\u002F_app","\u002F_error","\u002Fadmin","\u002Fblog\u002F[slug]","\u002Fdevlog"]};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()
|
self.__BUILD_MANIFEST = {__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static\u002Fchunks\u002Fpages\u002Findex.js"],"/_error":["static\u002Fchunks\u002Fpages\u002F_error.js"],"/admin":["static\u002Fchunks\u002Fpages\u002Fadmin.js"],"/admin/login":["static\u002Fchunks\u002Fpages\u002Fadmin\u002Flogin.js"],"/blog/[slug]":["static\u002Fchunks\u002Fpages\u002Fblog\u002F[slug].js"],"/devlog":["static\u002Fchunks\u002Fpages\u002Fdevlog.js"],sortedPages:["\u002F","\u002F_app","\u002F_error","\u002Fadmin","\u002Fadmin\u002Flogin","\u002Fblog\u002F[slug]","\u002Fdevlog"]};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()
|
||||||
27
.next/trace
27
.next/trace
File diff suppressed because one or more lines are too long
@ -8,13 +8,24 @@ const AdminLayout = ({ children }) => {
|
|||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
setIsLoggingOut(true);
|
setIsLoggingOut(true);
|
||||||
try {
|
try {
|
||||||
// Cookie löschen
|
// API-Route für Logout aufrufen
|
||||||
|
await fetch('/api/logout', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cookie clientseitig löschen (als Backup)
|
||||||
document.cookie = 'isAuthenticated=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
document.cookie = 'isAuthenticated=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
||||||
|
|
||||||
// Zur Login-Seite weiterleiten
|
// Zur Login-Seite weiterleiten
|
||||||
router.push('/admin/login');
|
router.push('/admin/login');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Logout-Fehler:', error);
|
console.error('Logout-Fehler:', error);
|
||||||
|
// Fallback: Cookie trotzdem löschen und weiterleiten
|
||||||
|
document.cookie = 'isAuthenticated=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
||||||
|
router.push('/admin/login');
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoggingOut(false);
|
setIsLoggingOut(false);
|
||||||
}
|
}
|
||||||
|
|||||||
17
pages/api/logout.js
Normal file
17
pages/api/logout.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
export default function handler(req, res) {
|
||||||
|
if (req.method !== 'POST') {
|
||||||
|
return res.status(405).json({ message: 'Method not allowed' });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Cookie serverseitig löschen
|
||||||
|
res.setHeader('Set-Cookie', [
|
||||||
|
'isAuthenticated=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; SameSite=Strict'
|
||||||
|
]);
|
||||||
|
|
||||||
|
res.status(200).json({ message: 'Logout successful' });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Logout API error:', error);
|
||||||
|
res.status(500).json({ message: 'Internal server error' });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,12 +1,9 @@
|
|||||||
import { useRouter } from 'next/router';
|
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import devlogData from '../../data/devlog.json';
|
import devlogData from '../../data/devlog.json';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
|
import { supabase } from '../../lib/supabase';
|
||||||
|
|
||||||
export default function BlogPost() {
|
export default function BlogPost({ blog }) {
|
||||||
const router = useRouter();
|
|
||||||
const { slug } = router.query;
|
|
||||||
const blog = devlogData.find((entry) => entry.slug === slug);
|
|
||||||
|
|
||||||
if (!blog) {
|
if (!blog) {
|
||||||
return (
|
return (
|
||||||
@ -40,8 +37,17 @@ export default function BlogPost() {
|
|||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
{blog.content && blog.content.map((item, index) =>
|
{blog.content && blog.content.map((item, index) => {
|
||||||
item.type === 'text' ? (
|
// Handle both old format (type/value) and new format (direct content)
|
||||||
|
if (typeof item === 'string') {
|
||||||
|
return (
|
||||||
|
<p key={index} className="text-gray-600 text-lg">
|
||||||
|
{item}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.type === 'text' ? (
|
||||||
<p key={index} className="text-gray-600 text-lg">
|
<p key={index} className="text-gray-600 text-lg">
|
||||||
{item.value}
|
{item.value}
|
||||||
</p>
|
</p>
|
||||||
@ -50,14 +56,25 @@ export default function BlogPost() {
|
|||||||
key={index}
|
key={index}
|
||||||
className="relative w-full h-64 rounded-lg overflow-hidden"
|
className="relative w-full h-64 rounded-lg overflow-hidden"
|
||||||
>
|
>
|
||||||
<Image
|
{/* Only render image if src is valid */}
|
||||||
src={item.value}
|
{item.value && (item.value.startsWith('/') || item.value.startsWith('http')) && (
|
||||||
alt={blog.title}
|
<Image
|
||||||
fill
|
src={item.value}
|
||||||
className="object-cover"
|
alt={blog.title}
|
||||||
/>
|
fill
|
||||||
|
className="object-cover"
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
|
{/* If no structured content, show description */}
|
||||||
|
{(!blog.content || blog.content.length === 0) && blog.description && (
|
||||||
|
<p className="text-gray-600 text-lg">
|
||||||
|
{blog.description}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -65,3 +82,65 @@ export default function BlogPost() {
|
|||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getServerSideProps({ params }) {
|
||||||
|
const { slug } = params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// First, try to find the blog post in Supabase
|
||||||
|
const { data: supabaseBlog, error } = await supabase
|
||||||
|
.from('devlog_entries')
|
||||||
|
.select('*')
|
||||||
|
.eq('slug', slug)
|
||||||
|
.single();
|
||||||
|
|
||||||
|
if (supabaseBlog && !error) {
|
||||||
|
// Found in Supabase, format the data
|
||||||
|
const blog = {
|
||||||
|
id: supabaseBlog.id,
|
||||||
|
title: supabaseBlog.title,
|
||||||
|
date: supabaseBlog.date,
|
||||||
|
description: supabaseBlog.description,
|
||||||
|
slug: supabaseBlog.slug,
|
||||||
|
image: supabaseBlog.image,
|
||||||
|
content: supabaseBlog.content || []
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
blog
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not found in Supabase, try the static JSON file
|
||||||
|
const staticBlog = devlogData.find((entry) => entry.slug === slug);
|
||||||
|
|
||||||
|
if (staticBlog) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
blog: staticBlog
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blog post not found
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
blog: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching blog post:', error);
|
||||||
|
|
||||||
|
// Fallback to static data
|
||||||
|
const staticBlog = devlogData.find((entry) => entry.slug === slug);
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
blog: staticBlog || null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user