diff --git a/app/write/[id]/page.tsx b/app/write/[id]/page.tsx
deleted file mode 100644
index e9d8d6b..0000000
--- a/app/write/[id]/page.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function ViewBlogPage() {
- // This will take a blog id as a parameter and fetch the blog from the database using the get_blog_by_id command.
-}
diff --git a/app/write/edit/page.tsx b/app/write/edit/page.tsx
new file mode 100644
index 0000000..fcd7ea8
--- /dev/null
+++ b/app/write/edit/page.tsx
@@ -0,0 +1,173 @@
+"use client";
+
+import { useSearchParams } from "next/navigation";
+import { useEffect, useState } from "react";
+import { invoke } from "@tauri-apps/api/core";
+import Link from "next/link";
+import { HomelabApp, Blog } from "@/types";
+
+export default function WritePage() {
+ const params = useSearchParams();
+
+ const blogId = params.get("id") || null;
+
+ if (!blogId) {
+ return (
+
+
+ No document ID provided.
+
+
+ );
+ }
+
+ const [blog, setBlog] = useState(null);
+ const [linkedApps, setLinkedApps] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ if (!blogId) return;
+
+ const fetchBlogAndApps = async () => {
+ try {
+ setLoading(true);
+ const currentBlog = (await invoke("get_blog", { id: blogId })) as
+ | Blog
+ | undefined;
+
+ if (!currentBlog) {
+ setError("Blog post not found.");
+ return;
+ }
+
+ setBlog(currentBlog);
+
+ // 2. Fetch the metadata for any bound/linked apps if they exist
+ if (currentBlog.reference && currentBlog.reference.length > 0) {
+ const apps = (await invoke("get_apps_by_id", {
+ ids: currentBlog.reference,
+ })) as HomelabApp[];
+ setLinkedApps(apps);
+ }
+ } catch (err) {
+ console.error("Failed to load blog page data:", err);
+ setError("An error occurred while loading the document.");
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchBlogAndApps();
+ }, [blogId]);
+
+ if (loading) {
+ return (
+
+
+ Loading document...
+
+
+ );
+ }
+
+ if (error || !blog) {
+ return (
+
+
+ {error || "Something went wrong."}
+
+
+ Go Back Home
+
+
+ );
+ }
+
+ return (
+
+ {/* Top Header Controls */}
+
+
+
+ {blog.title || "Untitled Document"}
+
+
+
+
+ Edit Document
+
+
+
+ {/* Main Reading Workspace Layout */}
+
+ {/* Left Side: Styled Canvas Viewport */}
+
+ {/* Using your exact editor style class 'prose max-w-none' to ensure uniform markdown formatting */}
+
+