aboutsummaryrefslogtreecommitdiffstats
path: root/generate.php
diff options
context:
space:
mode:
authorFrançois Kooman <fkooman@tuxed.net>2017-01-12 23:05:47 +0100
committerFrançois Kooman <fkooman@tuxed.net>2017-01-12 23:05:47 +0100
commit4fba1f88054a6945639c334e515705eda87a6e1a (patch)
tree4db243efba888cadb88e1f3c38a3bffcc600c31a /generate.php
parenta360a3e0a887094530a974f62907bef547ac42de (diff)
downloadwww.tuxed.net-4fba1f88054a6945639c334e515705eda87a6e1a.zip
www.tuxed.net-4fba1f88054a6945639c334e515705eda87a6e1a.tar.gz
www.tuxed.net-4fba1f88054a6945639c334e515705eda87a6e1a.tar.xz
fix everything, ready for live deploy
Diffstat (limited to 'generate.php')
-rw-r--r--generate.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/generate.php b/generate.php
index 00c8bdf..c829c66 100644
--- a/generate.php
+++ b/generate.php
@@ -7,6 +7,7 @@ use Michelf\MarkdownExtra;
$postDir = sprintf('%s/posts', __DIR__);
$pageDir = sprintf('%s/pages', __DIR__);
$outputDir = sprintf('%s/output', __DIR__);
+$blogOutputDir = sprintf('%s/blog', $outputDir);
$templateDir = sprintf('%s/views', __DIR__);
$blogTitle = "François' Blog";
@@ -25,6 +26,9 @@ $twig = new Twig_Environment($loader, ['strict_variables' => true]);
$postsList = [];
$pagesList = [];
+@mkdir($outputDir, 0755, true);
+@mkdir($blogOutputDir, 0755, true);
+
foreach (glob(sprintf('%s/*.md', $pageDir)) as $pageFile) {
$pageInfo = [];
@@ -102,9 +106,24 @@ usort($postsList, function ($a, $b) {
return strtotime($a['published']) < strtotime($b['published']);
});
-$indexPage = $twig->render(
+$siteIndexPage = $twig->render(
+ 'index.twig',
+ [
+ 'toRoot' => '',
+ 'pagesList' => $pagesList,
+ 'activePage' => 'index.html',
+ 'postsList' => $postsList,
+ 'pageTitle' => 'Blog',
+ 'blogTitle' => $blogTitle,
+ 'blogDescription' => $blogDescription,
+ 'blogAuthor' => $blogAuthor,
+ ]
+);
+
+$blogIndexPage = $twig->render(
'index.twig',
[
+ 'toRoot' => '../',
'pagesList' => $pagesList,
'activePage' => 'index.html',
'postsList' => $postsList,
@@ -120,6 +139,7 @@ foreach ($postsList as $post) {
$postPage = $twig->render(
'post.twig',
[
+ 'toRoot' => '../',
'pagesList' => $pagesList,
'activePage' => 'index.html',
'blogTitle' => $blogTitle,
@@ -129,7 +149,7 @@ foreach ($postsList as $post) {
'blogAuthor' => $blogAuthor,
]
);
- file_put_contents($outputDir.'/'.$post['fileName'], $postPage);
+ file_put_contents($blogOutputDir.'/'.$post['fileName'], $postPage);
}
}
@@ -138,6 +158,7 @@ foreach ($pagesList as $page) {
$pagePage = $twig->render(
'page.twig',
[
+ 'toRoot' => '',
'activePage' => $page['fileName'],
'pagesList' => $pagesList,
'blogTitle' => $blogTitle,
@@ -151,7 +172,8 @@ foreach ($pagesList as $page) {
}
}
-file_put_contents($outputDir.'/index.html', $indexPage);
+file_put_contents($outputDir.'/index.html', $siteIndexPage);
+file_put_contents($blogOutputDir.'/index.html', $blogIndexPage);
// copy img
@mkdir($outputDir.'/img');