@@ -25,7 +25,7 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
2525 . prepare (
2626 `
2727 SELECT
28- id, slug, title, locale,
28+ id, slug, title, subtitle, card_style, locale,
2929 type, status, dept,
3030 category, excerpt, summary,
3131 department_id, shadow_density, coherence_score,
@@ -62,7 +62,7 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
6262 . prepare (
6363 `
6464 SELECT
65- id, slug, title, locale,
65+ id, slug, title, subtitle, card_style, locale,
6666 type, status, dept,
6767 category, excerpt, summary,
6868 content_markdown,
@@ -94,6 +94,8 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
9494 const {
9595 id,
9696 title,
97+ subtitle,
98+ card_style,
9799 slug,
98100 locale,
99101 category,
@@ -114,6 +116,13 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
114116 if ( ! title ) return res . status ( 400 ) . json ( { error : "title is required" } ) ;
115117 if ( ! slug ) return res . status ( 400 ) . json ( { error : "slug is required" } ) ;
116118
119+ const incomingSubtitle =
120+ typeof subtitle === "string" ? subtitle . trim ( ) : null ;
121+
122+ // Allow "" to mean “auto”, store NULL
123+ const incomingCardStyle =
124+ typeof card_style === "string" && card_style . trim ( ) ? card_style . trim ( ) . toLowerCase ( ) : null ;
125+
117126 const noteLocale = normalizeLocale ( locale ) ;
118127 const noteType = String ( type ?? "labnote" ) ;
119128 const noteStatus = String ( status ?? ( published_at ? "published" : "draft" ) ) ;
@@ -157,7 +166,7 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
157166 // 1) Upsert metadata row (NO content_html writes, NO content_markdown column)
158167 db . prepare ( `
159168 INSERT INTO lab_notes (
160- id, title, slug, locale,
169+ id, title, subtitle, card_style, slug, locale,
161170 type, status, dept,
162171 category, excerpt, summary,
163172 department_id, shadow_density, coherence_score,
@@ -166,14 +175,16 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
166175 )
167176 VALUES (
168177 ?, ?, ?, ?,
169- ?, ?, ?,
178+ ?, ?, ?, ?, ?,
170179 ?, ?, ?,
171180 ?, ?, ?,
172181 ?, ?, ?,
173182 strftime('%Y-%m-%dT%H:%M:%fZ','now')
174183 )
175184 ON CONFLICT(slug, locale) DO UPDATE SET
176185 title=excluded.title,
186+ subtitle = COALESCE(excluded.subtitle, lab_notes.subtitle),
187+ card_style = COALESCE(excluded.card_style, lab_notes.card_style),
177188 type=excluded.type,
178189 status=excluded.status,
179190 dept = COALESCE(excluded.dept, lab_notes.dept),
@@ -190,12 +201,14 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
190201 ` ) . run (
191202 noteId ,
192203 title ,
204+ subtitle ,
205+ card_style ,
193206 slug ,
194207 noteLocale ,
195208
196- noteType ,
209+ resolvedType ,
197210 noteStatus ,
198- dept ?? null ,
211+ resolvedDepartment ,
199212
200213 category || "Uncategorized" ,
201214 excerpt || "" ,
@@ -240,9 +253,10 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
240253 slug,
241254 locale : noteLocale ,
242255 type : noteType ,
243- title,
256+ subtitle : incomingSubtitle ?? undefined ,
257+ card_style : incomingCardStyle ?? undefined ,
244258 status : noteStatus ,
245- published : normalizedPublishedAt ?? undefined ,
259+ published_at : normalizedPublishedAt ?? undefined ,
246260 dept : dept ?? null ,
247261 department_id : resolvedDepartment ,
248262 shadow_density : shadow_density ?? 0 ,
@@ -362,8 +376,6 @@ export function registerAdminRoutes(app: any, db: Database.Database) {
362376 }
363377 } ) ;
364378
365-
366-
367379 // ---------------------------------------------------------------------------
368380 // Admin: Publish Lab Note (protected)
369381 // ---------------------------------------------------------------------------
0 commit comments