Created
December 29, 2016 16:29
-
-
Save opdavies/385f7254c3c2a49ef5118ca35f332709 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Symfony\Component\Finder\Finder; | |
// Find all posts. | |
$files = Finder::create()->files()->in('../source/_posts')->name('*.md'); | |
foreach ($files as $file) { | |
$contents = file_get_contents($file->getPathname()); | |
// Find the opening front matter tag. | |
$position = strpos($contents, '---', 3); | |
// Prepend the extra front matter to the second tag. | |
$contents = substr_replace($contents, "use: [posts]\n---", $position, 3); | |
file_put_contents($file->getPathname(), $contents); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment