1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-23 05:16:03 +02:00

Flextype Core: Add ability to work with different types of content #212 #186

- FrontmatterParser implementation
This commit is contained in:
Awilum
2019-08-11 00:29:46 +03:00
parent c986506a98
commit 3a7848a90d

View File

@@ -32,10 +32,10 @@ class FrontmatterParser
{
$parts = preg_split('/^[\s\r\n]?---[\s\r\n]?$/sm', PHP_EOL . ltrim($content));
if (count($parts) < 3) {
return ['matter' => [], 'body' => $content];
return ['content' => $content];
}
return ['matter' => trim($parts[1]), 'body' => implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2))];
return YamlParser::decode(trim($parts[1])) + ['content' => implode(PHP_EOL . '---' . PHP_EOL, array_slice($parts, 2))];
}
public static function encode($input) : string