You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
1.0 KiB

<?php
namespace App\Services;
use Mni\FrontYAML\Parser;
use Spatie\YamlFrontMatter\YamlFrontMatter;
class ReplaceBlogService {
public function replaceFrontMatter($path = "")
{
$parser = new Parser();
if (is_dir($path)) {
$files = scandir($path);
foreach ($files as $file) {
if ($file == "." || $file == ".." | $file == ".DS_Store") {
continue;
}
$object = YamlFrontMatter::parse(file_get_contents($path . "/" . $file));
dump($object->matter());
dump($object->matter('title')); // => 'Example';
// dump($object->body()); // => 'Lorem ipsum.'
dump($object->title); // => 'Example';
// $document = $parser->parse($path . "/" . $file);
// $yaml = $document->getYAML();
// dump($yaml);
// $html = $document->getContent();
// dump($html);
exit;
}
}
}
}