feat: better content, initial omnisrv compat

This commit is contained in:
NaitLee 2025-09-26 18:34:59 +08:00
parent 1e75d0ee35
commit fd17056c12
11 changed files with 140 additions and 40 deletions

2
mk.sh
View file

@ -19,7 +19,7 @@ if ! php --version >>/dev/null; then
echo "error: Please install PHP, prefer version 8+"
exit 1
fi
if ! echo "<?php mb_strlen(\"hello\") ?>" | php 2>>/dev/null; then
if ! echo "<?php mb_strlen(\"\") ?>" | php 2>>/dev/null; then
echo "error: php_mbstring is not installed, dummy-ssg will not work"
exit 1
fi

View file

@ -66,6 +66,7 @@
top: 5em;
}
}
@media (max-width: 520px) {
.bio__pic {
top: 9em;

View file

@ -36,7 +36,7 @@ main {
max-width: 100%;
margin: 2em auto;
padding: 8pt;
line-height: 1.5;
line-height: 1.8;
}
nav {
@ -86,6 +86,20 @@ dd {
margin: 0 0 0 4pt;
}
table {
border-collapse: collapse;
/* margin: 0 auto; */
}
tr {
border-bottom: 1px solid var(--shade);
}
thead, tbody tr:nth-last-child(1) {
border-bottom: 2px solid var(--fore);
}
td {
padding: 2pt 8pt;
}
@media (max-width: 520px) {
nav {
flex-direction: column;

View file

@ -1,12 +1,10 @@
---
{
"title": "Amaharacya.one"
}
title Amaharacya.one
---
一隻元氣滿滿的貓娘
有時候我會發一點點[文章](/pages.html)
有時候我會發一點點[文章](/page)
我的一些信息:

7
src/page/index.md Normal file
View file

@ -0,0 +1,7 @@
---
title 文章 | Amaharacya.one
---
# 文章
## 索引

View file

@ -0,0 +1,29 @@
# 本站提供伺服器出租服務
## 簡介
本站提供遊戲伺服器出租服務,由 [MCSManage](https://www.mcsmanager.com/) 驅動。
支援 Minecraft 和主流的可開服的聯機遊戲。
## 價格
貨幣皆為人民幣 (CNY)。
### Minecraft
純淨服(任何版本都支援,主流版本提供<abbr title="Plugin, 臺譯「外掛」">插件</abbr>支援服務需加價 10 元)每月 25 元。
Mod 服(具體價格依據遊戲版本和 mod 數量決定)底價為每月 35 元。
### Steam 聯機遊戲(試運營中)
需聯絡客服,根據具體情況制定價格,底價為每月 35 元。
## 客服聯絡方式
| | |
|:-:|:--|
| 微信 | amaharaneko56 |
| QQ | 2139623169 |
| 郵箱 | amaharaneko@disroot.org |

View file

@ -1,26 +0,0 @@
#本站提供服務器出租服務
##簡介
本站提供遊戲服務器出租服務,由[MCSManage](https://www.mcsmanager.com/)驅動。
支持Mc和主流的可開服的聯機遊戲。
##價格
###MC
純淨服任何版本都支持主流版本提供插件支持服務需加價10元每月25元。
Mod服具體價格依據遊戲版本和mod數量決定底價爲每月35元。
###Steam聯機遊戲(試運營中)
需聯繫客服根據具體情況制定價格底價爲每月35元。
##客服聯繫方式
微信 amaharaneko56
QQ 2139623169
郵箱 amaharaneko@disroot.org

View file

@ -1,5 +0,0 @@
---
{
"title": "文章 | Amaharacya.one"
}
---

63
src/tmpl.html Normal file
View file

@ -0,0 +1,63 @@
<!DOCTYPE html>
<!-- Powered by omnisrv -->
<html lang="{{if .Head.lang}}{{.Head.lang}}{{else}}en{{end}}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.Title}}</title>
<link rel="stylesheet" href="/assets/main.css" />
{{- if eq .Url "/"}}<link rel="stylesheet" href="/assets/frontpage.css" />{{end -}}
</head>
<body>
{{- template "nav" -}}
<main>
{{if eq .Url "/" -}}
{{- template "bio" . -}}
{{- else if eq .Url "/page" -}}
{{- template "pages" . -}}
{{- else if .Contentful -}}
{{- .Html -}}
{{- else -}}
<p>此頁為空</p>
{{- end}}
</main>
</body>
</html>
{{define "nav"}}
<nav>
<a href="/" class="logo-link">
<svg class="logo" height="36" viewBox="0 0 512 64" aria-label="Amaharacya.one">
<use xlink:href="/assets/logo.svg#amaharacya-one-logo" />
</svg>
</a>
<div class="nav__links">
<a href="/pages">文章</a>
<a href="/">關於</a>
</div>
</nav>
{{end}}
{{define "bio"}}
<div class="bio">
<div class="bio__pic">
<img height="640" src="/assets/amahara-full.webp" alt="雨晴的立繪">
</div>
<div class="bio__name">
<h1 class="bio__name__main">緒山 雨晴</h1>
<p class="bio__name__sub">Amahara Oyama</p>
</div>
<div class="bio__intro">
{{.Html}}
</div>
</div>
{{end}}
{{define "pages"}}
{{.Html}}
<ul>
{{range .List -}}
<li><a href="{{.Url}}">{{.Date}} | {{.Title}}</a></li>
{{- end}}
</ul>
{{end}}

View file

@ -1,4 +1,24 @@
<!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">
@ -12,7 +32,7 @@
<main>
<?php
if ($page["path"] === "index.md") include "bio.php";
else if ($page["path"] === "pages.md") include "pages-index.php";
else if ($page["path"] === "page/index.md") include "page-index.php";
else if (!empty($page["content"])) echo $page["content"];
else echo "此頁為空";
?>

View file

@ -29,8 +29,7 @@ array_multisort(
$child_pages
);
?>
<h1>文章</h1>
<h2>索引</h2>
<?php echo $page["content"] ?>
<ul class="pages-index">
<?php
foreach ($child_pages as $page)