Added redirects.php
This commit is contained in:
parent
4b743199a9
commit
53882d1e01
32
scripts/redirects.php
Normal file
32
scripts/redirects.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env php
|
||||
|
||||
<?php
|
||||
|
||||
$template = <<<EOS
|
||||
|
||||
---
|
||||
layout: redirect
|
||||
destination: %DESTINATION%
|
||||
---
|
||||
|
||||
EOS;
|
||||
|
||||
$filename = dirname(__FILE__) . '/redirects.csv';
|
||||
|
||||
$row = 1;
|
||||
|
||||
if (($handle = fopen($filename, 'r')) !== FALSE) {
|
||||
while (($data = fgetcsv($handle, filesize($filename))) !== FALSE) {
|
||||
var_dump($data[0]);
|
||||
$templateData = [
|
||||
'%DESTINATION%' => $destination,
|
||||
];
|
||||
|
||||
$output = strtr($template, $templateData);
|
||||
file_put_contents("source/{$data[0]}.html", $output);
|
||||
|
||||
$row++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose($handle);
|
Loading…
Reference in a new issue