-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.php
More file actions
51 lines (43 loc) · 1.53 KB
/
page.php
File metadata and controls
51 lines (43 loc) · 1.53 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
require 'includes/functions.php';
$config = require 'config.php';
$Parsedown = new Parsedown();
if (method_exists($Parsedown, 'setSafeMode')) {
$Parsedown->setSafeMode(true);
}
$pagesDir = 'pages';
$slug = normalizeSlug($_GET['slug'] ?? '');
$page = $slug ? findMarkdownBySlug($slug, $pagesDir) : false;
if ($page) {
$metadata = $page['metadata'];
$content = removeFrontMatter($page['content']);
$htmlContent = $Parsedown->text($content);
$imageUrl = !empty($metadata['image']) ? $metadata['image'] : $config['default_image'];
} else {
http_response_code(404);
require __DIR__ . '/404.php';
exit;
}
$base = rtrim($config['base_path'] ?? '/', '/');
$active = $slug;
$headTitle = pageTitle($metadata, $config, 'Page');
$headDesc = pageDescription($metadata, $config);
$headCanon = rtrim($config['site_url'], '/') . '/page/' . urlencode($slug);
$headImage = $imageUrl;
include 'includes/header.php';
?>
<div class="hero-banner" style="background-image: url('<?= html($imageUrl) ?>');">
<div class="hero-content">
<h1><?= html($metadata['title'] ?? 'Untitled') ?></h1>
<p><?= html(formatDate($metadata['date'] ?? '')) ?></p>
</div>
</div>
<main class="container my-5">
<div class="row">
<div class="col-12">
<?= $htmlContent ?>
<a href="<?= $base ?>/" class="btn btn-outline-secondary mt-4">← Back</a>
</div>
</div>
</main>
<?php include 'includes/footer.php'; ?>