mirror of
https://github.com/suk-ws/ph-Bookshelf.git
synced 2025-02-24 23:20:52 +08:00
为旧的标题策略做出兼容: 当这个功能开启时,如果输出检测到markdown内没有填入一级标题,则会自动以 book.xml 中声明的页面标题生成一级标题。 添加的配置: - 旧的页面标题策略兼容 : 默认 false,可选 true - 代码块背景色 : 默认跟随样式表fallback,可填任意 css 支持颜色 - 代码块 highlight.js 高亮 : 默认 true,可选 false - highlight.js 主题 : 默认 atom-one-dark,可填任意字符串(但是没有对应主题会无法使用 - 彩虹列表标记效果 : 默认 false,可选 true
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
require_once "./src/Data/SiteMeta.php";
|
|
require_once "./src/Element/BookContent/BookContented.php";
|
|
require_once "./src/Element/BookContent/Page.php";
|
|
|
|
class PageMeta {
|
|
|
|
public static BookContented $book;
|
|
public static Page $page;
|
|
public static bool $isMainPage = false;
|
|
|
|
public static function getPageTitle (): string {
|
|
return self::$page->getName()." - ".self::$book->getName();
|
|
}
|
|
|
|
public static function getDescription (): string {
|
|
return ""; // todo wip description
|
|
}
|
|
|
|
public static function getConfigurationLevelBook (string $key): ?string {
|
|
$value = SiteMeta::getConfigurationLevelShelf($key);
|
|
$valueAttr = self::$book->getConfiguration($key);
|
|
if ($valueAttr != null) $value = $valueAttr;
|
|
return $value;
|
|
}
|
|
|
|
public static function getConfigurationLevelPage (string $key): ?string {
|
|
$value = self::getConfigurationLevelBook($key);
|
|
$valueAttr = self::$page->getConfiguration($key);
|
|
if ($valueAttr != null) $value = $valueAttr;
|
|
return $value;
|
|
}
|
|
|
|
public static function compatibilityOldTitlePolicy (): bool {
|
|
if (self::getConfigurationLevelPage("compatibility.article.title.oldversion") == "true")
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
public static function highlightJsTheme (): string {
|
|
$theme = trim(self::getConfigurationLevelPage("customization.article.codeblock.highlightjs.theme"));
|
|
if (empty($theme)) return "atom-one-dark";
|
|
return $theme;
|
|
}
|
|
|
|
}
|