Last active
March 12, 2018 10:15
-
-
Save bastianallgeier/452084d6a3fbd013ec73b71fc470e87c to your computer and use it in GitHub Desktop.
This file contains 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
title: Some title | |
date: 2018-03-12 | |
Text: Lorem ipsum … |
This file contains 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 'kirby/bootstrap.php'; | |
// get the current list of blog articles | |
$articles = page('blog')->children(); | |
// scan a directory with yaml files for each post | |
$files = Dir::read(__DIR__ . '/articles'); | |
foreach ($files as $filename) { | |
// read each yaml file | |
$yaml = Data::read(__DIR__ . '/articles/' . $filename); | |
$slug = Str::slug($yaml['title']); | |
$template = 'article'; | |
$articles->create($slug, $template, [ | |
'title' => $yaml['title'], | |
'date' => $yaml['date'], | |
'text' => $yaml['text'] | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment