fix: enable live editing on homepage with {...homepage.edit.field} attributes

Adds content binding on Base component for homepage live editing navigation.
Uses homepage.id (entry ULID) not homepage.data.id (not in homepage schema).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kunthawat Greethong
2026-04-30 13:11:02 +07:00
parent 07725f9023
commit 8094cec877

View File

@@ -1,13 +1,14 @@
--- ---
import { getEmDashEntry } from "emdash"; import { getEmDashEntry } from "emdash";
import { Image } from "emdash/ui";
import Base from "../layouts/Base.astro"; import Base from "../layouts/Base.astro";
const { entry: homepage } = await getEmDashEntry("homepage", "main"); const { entry: homepage } = await getEmDashEntry("homepage", "main");
Astro.cache.set(homepage.cacheHint); Astro.cache.set(homepage.cacheHint);
const d = homepage.data; const d = homepage.data;
--- ---
<Base title="EmDash CMS - Self-Hosted for Astro" description="Fully self-hosted CMS for Astro. No cloud required, fully local, with admin panel, authentication, and plugin system."> <Base title="EmDash CMS - Self-Hosted for Astro" description="Fully self-hosted CMS for Astro. No cloud required, fully local, with admin panel, authentication, and plugin system."
content={{ collection: "homepage", id: homepage.id, slug: "main" }}
>
<main class="landing"> <main class="landing">
<!-- Hero Section --> <!-- Hero Section -->
<section class="hero"> <section class="hero">
@@ -34,12 +35,8 @@ const d = homepage.data;
</a> </a>
</div> </div>
</div> </div>
<div class="hero-visual" {...homepage.edit.hero_image}> <div class="hero-visual">
{d.hero_image?.src && ( <div class="code-window">
<Image image={d.hero_image} />
)}
{!d.hero_image?.src && (
<div class="code-window">
<div class="code-header"> <div class="code-header">
<span class="dot red"></span> <span class="dot red"></span>
<span class="dot yellow"></span> <span class="dot yellow"></span>