amaharacya.one/tpl/default.php

41 lines
No EOL
1.2 KiB
PHP

<!DOCTYPE html>
<!-- Powered by dummy-ssg -->
<?php
// let's use simple key-value headers instead of json
$raw = file_get_contents("src/" . $page["path"]);
preg_match('/^---\n\s*(.*?)\s*\n---\n/s', $raw, $matches);
if (!empty($matches[1])) {
foreach (explode("\n", $matches[1]) as $line) {
$line = trim($line);
if ($line === '') {
continue;
}
$kv = explode(' ', $line, 2);
if (empty($kv[1])) {
$page[$kv[0]] = true;
} else {
$page[$kv[0]] = $kv[1];
}
}
}
?>
<html lang="<?php if (empty($page["lang"])) echo "zh-TW"; else echo $page["lang"]; ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $page["title"] ?></title>
<link rel="stylesheet" href="/assets/main.css" />
<?php if ($page["path"] === "index.md") echo "<link rel=\"stylesheet\" href=\"/assets/frontpage.css\" />" ?>
</head>
<body>
<?php include "nav.php" ?>
<main>
<?php
if ($page["path"] === "index.md") include "bio.php";
else if ($page["path"] === "page/index.md") include "page-index.php";
else if (!empty($page["content"])) echo $page["content"];
else echo "此頁為空";
?>
</main>
</body>
</html>