Merge branch 'feature/redirects'
This commit is contained in:
commit
7817c3d274
5
scripts/redirects.csv
Normal file
5
scripts/redirects.csv
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
old,new
|
||||||
|
about,/
|
||||||
|
cv,https://gist.github.com/opdavies/d096d553b80140a342d4
|
||||||
|
portfolio,/
|
||||||
|
work,/
|
|
34
scripts/redirects.php
Normal file
34
scripts/redirects.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$template = <<<EOS
|
||||||
|
---
|
||||||
|
layout: redirect
|
||||||
|
destination: %DESTINATION%
|
||||||
|
---
|
||||||
|
|
||||||
|
EOS;
|
||||||
|
|
||||||
|
$filename = dirname(__FILE__) . '/redirects.csv';
|
||||||
|
|
||||||
|
$row = 0;
|
||||||
|
|
||||||
|
if (($handle = fopen($filename, 'r')) !== FALSE) {
|
||||||
|
while (($data = fgetcsv($handle, filesize($filename))) !== FALSE) {
|
||||||
|
$row++;
|
||||||
|
|
||||||
|
if ($row > 1) {
|
||||||
|
$templateData = [
|
||||||
|
'%DESTINATION%' => $data[1],
|
||||||
|
];
|
||||||
|
|
||||||
|
$output = strtr($template, $templateData);
|
||||||
|
file_put_contents("source/{$data[0]}.html", $output);
|
||||||
|
|
||||||
|
echo "Written to {$data[0]}.html\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($handle);
|
|
@ -1,4 +0,0 @@
|
||||||
---
|
|
||||||
layout: redirect
|
|
||||||
destination: https://gist.github.com/opdavies/d096d553b80140a342d4
|
|
||||||
---
|
|
Loading…
Reference in a new issue