forked from chrisullyott/csv-to-grav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.php
35 lines (26 loc) · 917 Bytes
/
convert.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
date_default_timezone_set('UTC');
include 'vendor/autoload.php';
$conversion = new CsvToGrav('example.csv');
// Set a directory for all posts.
$conversion->setOutputDir('user/pages/01.blog');
// Set the column map (Grav -> CSV).
$conversion->setColumnMap(array(
'title' => 'title_field', // string
'date' => 'date_field', // string
'html' => 'html_field', // string
'author' => 'author_field', // string
'category' => 'category_field', // comma-separated list
'tag' => 'tag_field' // comma-separated list
));
// Set metadata which will be the same for all posts.
$conversion->setMetaData(array(
'generator' => 'Grav',
'og:locale' => 'en_US',
'og:type' => 'article'
));
// Set whether posts are published default.
$conversion->setIsPublished(false);
// Generate.
$count = $conversion->build();
echo "Created {$count} items.\n";