Skip to content

Commit f985751

Browse files
authored
Merge pull request #1728 from hydephp/fix-undefined-array-key-exception-for-empty-markdown-pages
Fix undefined array key exception for empty Markdown pages
2 parents d5fbc71 + 7fd4aa2 commit f985751

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

composer.lock

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/framework/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"illuminate/view": "^10.0",
2828
"symfony/yaml": "^6.0",
2929
"league/commonmark": "^2.2",
30-
"spatie/yaml-front-matter": "^2.0.7",
30+
"spatie/yaml-front-matter": "^2.0.9",
3131
"torchlight/torchlight-commonmark": "^0.5.5"
3232
},
3333
"suggest": {

packages/framework/tests/Feature/MarkdownFileParserTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,19 @@ public function testParsedMarkdownPostContainsValidFrontMatter()
8484
$this->assertSame('Mr. Hyde', $post->matter('author'));
8585
$this->assertSame('blog', $post->matter('category'));
8686
}
87+
88+
public function testCanParseMarkdownFileWithFrontMatterAndNoMarkdownBody()
89+
{
90+
file_put_contents(Hyde::path('_posts/test-post.md'), "---\nfoo: bar\n---");
91+
92+
$document = MarkdownFileParser::parse('_posts/test-post.md');
93+
94+
$this->assertInstanceOf(MarkdownDocument::class, $document);
95+
$this->assertEquals('', $document->markdown);
96+
$this->assertSame('', $document->markdown->body());
97+
98+
$this->assertEquals(FrontMatter::fromArray([
99+
'foo' => 'bar',
100+
]), $document->matter);
101+
}
87102
}

0 commit comments

Comments
 (0)