Refactor post loading logic in AdminPage to separate filename and folder path; enhance edit button functionality for improved post management.
This commit is contained in:
@@ -789,7 +789,13 @@ export default function AdminPage() {
|
|||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<h3 className="text-xl font-semibold flex-1">{post.title}</h3>
|
<h3 className="text-xl font-semibold flex-1">{post.title}</h3>
|
||||||
<button
|
<button
|
||||||
onClick={() => loadPostRaw(post.slug, currentPath.join('/'))}
|
onClick={() => {
|
||||||
|
// Split post.slug into folder and filename
|
||||||
|
const slugParts = post.slug.split('/');
|
||||||
|
const filename = slugParts[slugParts.length - 1];
|
||||||
|
const folder = slugParts.length > 1 ? slugParts.slice(0, -1).join('/') : currentPath.join('/');
|
||||||
|
loadPostRaw(filename, folder);
|
||||||
|
}}
|
||||||
className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 text-lg font-bold shadow focus:outline-none focus:ring-2 focus:ring-blue-400"
|
className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 text-lg font-bold shadow focus:outline-none focus:ring-2 focus:ring-blue-400"
|
||||||
>
|
>
|
||||||
✏️ Edit
|
✏️ Edit
|
||||||
|
|||||||
Reference in New Issue
Block a user