-
Notifications
You must be signed in to change notification settings - Fork 2
The Simple Starter
Sebastian Kolind Sørensen edited this page Feb 1, 2021
·
6 revisions
This is a simple starter for Volcano. It gives you an idea of how to add a simple HTML structure to your content.
# /app.php
<?php
use Volcano\Volcano;
return new Volcano();
# site/theme/index.php
<?php
$app = require __DIR__ . '/../../app.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
# Get the "meta data" title
<title>My site — <?php echo $app->getMeta('title');?></title>
# and description
<meta name="description" content="<?php echo $app->getMeta('description');?>">
</head>
<body>
# $app->render() will take care of resolving your app and show your content from either a Page, Post or Template.
<?php echo $app->render(); ?>
</body>
</html>
You might want to have multiple templates with the same HTML header and footer, which is why it is common to move some of the HTML into their own files, which you can later require in a template.
You could do something like this:
# file structure
- site
- theme
index.php
header.php
footer.php
- templates
posts.php
app.php
# site/theme/header.php
<?php
$app = require __DIR__ . '/../../app.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
# Get the "meta data" title
<title>My site — <?php echo $app->getMeta('title');?></title>
# and description
<meta name="description" content="<?php echo $app->getMeta('description');?>">
</head>
# site/theme/footer.php
</body>
</html>
<?php
# site/theme/templates/posts.php
# when you visit https://your-site.com/posts you would see this
$app = require __DIR__ . '/../../app.php';
# require the header.php we just created
require __DIR__ . '/../theme/header.php';
foreach ($app->getEntries('posts') as $post) {
# posts/hello-world.md -> <a href="/hello-world">Hello World</a>
echo '<a href="' . $post->link() . '">' . $post->getMeta('title') . '</a>';
}
# require the footer.php we just created
require __DIR__ . '/../theme/header.php';