From b2389ffcad3029837caa28dd3430ded173484352 Mon Sep 17 00:00:00 2001 From: Rinat <95545985+RinatMadreiter@users.noreply.github.com> Date: Wed, 1 Jul 2026 00:20:42 +0200 Subject: [PATCH] fix: collection filename default ignores explicit format, causing entries to disappear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a collection sets format: json (or yaml/toml) but doesn't set filename, normalizeContentEntry in lib/config.ts still defaults filename to "{year}-{month}-{day}-{primary}.md", so extension resolves to "md" regardless of the declared format. The collection listing endpoint then filters out every file that doesn't end in .md, returning an empty entry list with no error — entries silently vanish from the CMS UI even though the files exist in the repo. Reproduced with a format: json collection containing only .json files. Fix: derive the default filename's extension from format when it's explicitly set. --- lib/config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/config.ts b/lib/config.ts index 222bca1d4..f98e18412 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -268,7 +268,16 @@ const normalizeContentEntry = ( } } if (item.filename == null && item.type === "collection") { - item.filename = "{year}-{month}-{day}-{primary}.md"; + const formatExtensions: Record = { ++ json: "json", ++ toml: "toml", ++ yaml: "yaml", ++ "json-frontmatter": "md", ++ "toml-frontmatter": "md", ++ "yaml-frontmatter": "md", ++ }; ++ const ext = item.format != null ? formatExtensions[item.format] : undefined; ++ item.filename = `{year}-{month}-{day}-{primary}.${ext ?? "md"}`; } if (item.extension == null) { const filename = item.type === "file" ? item.path : item.filename;