Emit an empty tag list in published VuePress articles
This commit is contained in:
1 parent
df38272f52
commit
e2f2e84185
1 file changed
+15
-1
@@ -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))) {
|
||||
|
||||
Reference in new issue
Block a user