diff --git a/laravel/app/ContentCenter/Publication.php b/laravel/app/ContentCenter/Publication.php index ccc21c82..b80c83d4 100644 --- a/laravel/app/ContentCenter/Publication.php +++ b/laravel/app/ContentCenter/Publication.php @@ -70,7 +70,7 @@ final class Publication $this->atomic($receipt, json_encode($record, JSON_THROW_ON_ERROR), 0600); $old = is_file($path) ? file_get_contents($path) : null; try { - $this->atomic($path, $artifact['markdown'], 0644); + $this->atomic($path, self::siteMarkdown($artifact['markdown']), 0644); (new WeeklyRanking($publisher))->renderCurrent(); $publisher->build(); } catch (\Throwable) { @@ -161,6 +161,20 @@ final class Publication }); } + public static function siteMarkdown(string $markdown): string + { + $end = strpos($markdown, "\n---\n", 4); + if (! str_starts_with($markdown, "---\n") || $end === false) { + return $markdown; + } + // Symfony YAML dumps an empty array as a mapping by default. Plume expects tag strings. + // Keep the signed artifact untouched and normalize only its static-site representation. + $frontmatter = substr($markdown, 0, $end); + $normalized = preg_replace('/^tags:\h*\{\h*\}\h*$/m', 'tags: []', $frontmatter, 1); + + return $normalized.substr($markdown, $end); + } + private function atomic(string $path, string $data, int $mode): void { if (! is_dir(dirname($path))) {