From 05923f255b32461a084ede24f896f45f998bfd21 Mon Sep 17 00:00:00 2001 From: Chili Palmer Date: Thu, 28 May 2026 21:36:10 +0200 Subject: [PATCH] fix: A1-4 omit doNotTranslate from frontmatter when false per spec --- SPECGAPS.md | 2 +- lib/bds/posts/file_sync.ex | 2 +- test/bds/posts_test.exs | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/SPECGAPS.md b/SPECGAPS.md index f504b5e..1f8106b 100644 --- a/SPECGAPS.md +++ b/SPECGAPS.md @@ -13,7 +13,7 @@ Gap categories: **SC** = spec correct, fix code | **CS** = code correct, update | A1-1 | ~~No `archived→draft` or `archived→published` transition~~ | post.allium:121-122 | `unarchive_post/1` implemented, `publish_post` already handled archived→published | **Resolved:** `unarchive_post/1` in posts.ex restores content from disk, UI wired via quick actions, 4 tests added | | A1-2 | ~~`DeletePost` must delete translations + translation files~~ | post.allium:209-212 | `delete_post/1` now fetches translations before cascade-delete and removes their files from disk | **Resolved:** translation file cleanup added to `delete_post/1` in posts.ex, test added | | A1-3 | ~~Publish must delete old file when path changes~~ | engine_side_effects.allium:73-74 | `publish_post` now deletes old file when `file_path` changes | **Resolved:** old file deletion added to `publish_post/1` in posts.ex, test added | -| A1-4 | `doNotTranslate: false` written to frontmatter despite "only when true" | frontmatter.allium:398 | `lib/bds/frontmatter.ex:38-39` writes false | Fix code: omit `doNotTranslate` when false | +| A1-4 | ~~`doNotTranslate: false` written to frontmatter despite "only when true"~~ | frontmatter.allium:398 | `file_sync.ex:78` now converts false→nil so serializer omits the key | **Resolved:** doNotTranslate omitted from frontmatter when false, test added | | A1-5 | Auto-save after 3000ms idle | editor_post.allium:183-188 | No auto-save timer | Fix code: implement auto-save on idle + unmount + tab switch | | A1-6 | On-demand rendering in preview server | preview.allium:53-93 | Server serves static pre-generated files | Fix code: implement on-demand template rendering for post/archive/language routes | | A1-7 | Template lookup must use all 4 levels (post→tag→category→default) | template_context.allium:267-277 | Only levels 1 and 4 implemented; tag/category fallback unused | Fix code: implement levels 2-3 in template_selection.ex | diff --git a/lib/bds/posts/file_sync.ex b/lib/bds/posts/file_sync.ex index 9d45e1f..8553dc1 100644 --- a/lib/bds/posts/file_sync.ex +++ b/lib/bds/posts/file_sync.ex @@ -75,7 +75,7 @@ defmodule BDS.Posts.FileSync do {"status", :published}, {"author", post.author}, {"language", post.language}, - {"doNotTranslate", post.do_not_translate}, + {"doNotTranslate", post.do_not_translate || nil}, {"templateSlug", post.template_slug}, {"createdAt", post.created_at}, {"updatedAt", post.updated_at}, diff --git a/test/bds/posts_test.exs b/test/bds/posts_test.exs index b918b0b..3b02279 100644 --- a/test/bds/posts_test.exs +++ b/test/bds/posts_test.exs @@ -188,6 +188,26 @@ defmodule BDS.PostsTest do refute File.exists?(full_path <> ".tmp") end + test "publish_post omits doNotTranslate from frontmatter when false", %{ + project: project, + temp_dir: temp_dir + } do + assert {:ok, post} = + BDS.Posts.create_post(%{ + project_id: project.id, + title: "Normal Post", + content: "body" + }) + + assert post.do_not_translate == false + assert {:ok, published} = BDS.Posts.publish_post(post.id) + + full_path = Path.join(temp_dir, published.file_path) + file_contents = File.read!(full_path) + + refute file_contents =~ "doNotTranslate" + end + test "publish_post deletes old file when file path changes", %{ project: project, temp_dir: temp_dir