diff --git a/src/Page.php b/src/Page.php index d180da6..bd04f71 100644 --- a/src/Page.php +++ b/src/Page.php @@ -158,7 +158,7 @@ private function parseContents(): array ); $parsedMetadata = $defaultMetadata; } - $metadata = array_merge($defaultMetadata, $parsedMetadata); + $metadata = array_merge($defaultMetadata, $parsedMetadata ?? []); $body = substr($contents, $frontmatterClosePos + $hyphenCount); } else { $metadata = $defaultMetadata; diff --git a/tests/PageTest.php b/tests/PageTest.php index 2d982e2..8d763a2 100644 --- a/tests/PageTest.php +++ b/tests/PageTest.php @@ -165,6 +165,11 @@ public function provideWriting(): array ['template' => 'lorem'], 'Ipsum.', ], + 'empty Yaml and no body' => [ + "---\n---\n", + ['template' => 'index'], + '', + ], ]; } }