feat: H1 conversion on the API, markdown and import paths

- the /_journal/api/v1 post writes convert default and translated content
  in the write transaction and answer an additive notices key
- journal:import-posts converts and prints the converted count
  (ImportFromDirConfig, ImportStats.H1Converted)
- a category's pillar text saved in the admin answers
  editor.h1_converted_category
- every GET /categories row reports content_h1_to_h2 (additive key)
This commit is contained in:
Jakub Zych
2026-11-04 09:51:47 +01:00
parent 305f94afd9
commit faaa9b0f55
11 changed files with 459 additions and 42 deletions

View File

@@ -25,14 +25,14 @@ func TestSerializeCategoryNodeContent(t *testing.T) {
byParent := map[uint][]models.Category{1: {child}}
counts := map[uint]int64{1: 2}
row := serializeCategoryNode(&root, byParent, counts, true)
row := serializeCategoryNode(&root, byParent, counts, true, true)
if row == nil {
t.Fatal("root row is nil")
}
if got, ok := row["content"].(string); !ok || got != html {
t.Fatalf("root content = %#v, want %q", row["content"], html)
}
wantRoot := []string{"children", "content", "description", "id", "name", "nest_depth", "parent_id", "post_count", "slug"}
wantRoot := []string{"children", "content", "content_h1_to_h2", "description", "id", "name", "nest_depth", "parent_id", "post_count", "slug"}
if got := sortedCategoryKeys(row); !reflect.DeepEqual(got, wantRoot) {
t.Fatalf("root keys = %v, want %v", got, wantRoot)
}
@@ -44,12 +44,12 @@ func TestSerializeCategoryNodeContent(t *testing.T) {
if !present || v != nil {
t.Fatalf("child content = %#v (present %v), want nil", v, present)
}
wantChild := []string{"content", "description", "id", "name", "nest_depth", "parent_id", "post_count", "slug"}
wantChild := []string{"content", "content_h1_to_h2", "description", "id", "name", "nest_depth", "parent_id", "post_count", "slug"}
if got := sortedCategoryKeys(kids[0]); !reflect.DeepEqual(got, wantChild) {
t.Fatalf("child keys = %v, want %v", got, wantChild)
}
listed := serializeCategoryNode(&root, byParent, counts, false)
listed := serializeCategoryNode(&root, byParent, counts, false, true)
if listed == nil {
t.Fatal("root omitted without include_empty")
}