mirror of
https://github.com/suk-ws/ph-Bookshelf.git
synced 2025-02-23 22:58:49 +08:00
add Title for book contents
This commit is contained in:
parent
0329392dd6
commit
31611969bf
@ -25,6 +25,7 @@
|
||||
|
||||
--color-sidebar-background: var(--bcm-color-table-background);
|
||||
--color-font-sidebar: var(--color-font-base);
|
||||
--color-font-sidebar-title: #9e77e5;
|
||||
--color-scrollbar-sidebar-background: none;
|
||||
--color-scrollbar-sidebar-foreground: var(--color-menu-child-list-line);
|
||||
|
||||
@ -421,6 +422,21 @@ body {
|
||||
background: var(--color-menu-list-separator);
|
||||
}
|
||||
|
||||
#sidebar > .menu-container > .menu .menu-title {
|
||||
display: block;
|
||||
position: relative;
|
||||
padding: 0.75rem 0 0;
|
||||
margin: 0;
|
||||
font-size: 0.8em;
|
||||
color: var(--color-font-sidebar-title);
|
||||
}
|
||||
|
||||
#sidebar > .menu-container > .menu .menu-title:before {
|
||||
content: "•";
|
||||
position: absolute;
|
||||
left: -1em;
|
||||
}
|
||||
|
||||
#sidebar > .menu-container > .menu .menu-item {
|
||||
display: block;
|
||||
padding: 0.55rem 0;
|
||||
|
@ -29,6 +29,7 @@
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:group ref="bookContent" />
|
||||
<xs:element name="Separator" />
|
||||
<xs:element name="Title" type="xs:string" />
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
const APP_NAME = "ph-Bookshelf";
|
||||
|
||||
const VERSION = "0.5.0-alpha8";
|
||||
const VERSION = "0.5.0-alpha9";
|
||||
const CHANNEL = "suk-ws";
|
||||
const BRANCH = "config-v2.0";
|
||||
|
@ -6,7 +6,6 @@ use Exception;
|
||||
use SukWs\Bookshelf\Data\SiteConfig\ConfigName;
|
||||
use SukWs\Bookshelf\Data\SiteConfig\RobotsPolicy;
|
||||
use SukWs\Bookshelf\Element\Bookshelf;
|
||||
use SukWs\Bookshelf\Resource\Assets;
|
||||
use SukWs\Bookshelf\Resource\Data;
|
||||
|
||||
class SiteMeta {
|
||||
@ -52,7 +51,7 @@ class SiteMeta {
|
||||
"/assets/bread-card-markdown-heading-permalink.css?ver=1",
|
||||
(PageMeta::getConfigurationLevelPage(ConfigName::ext_listing_rainbow)=="true"?
|
||||
"/assets/bread-card-markdown-enhanced-listing-rainbow.css?ver=2":null),
|
||||
"/assets/main.css?ver=1",
|
||||
"/assets/main.css?ver=2",
|
||||
),
|
||||
self::getPrismPluginsCss(PageMeta::prismPlugins())
|
||||
);
|
||||
|
@ -57,6 +57,9 @@ class Chapter {
|
||||
case "Separator":
|
||||
$node->children[] = Separator::parse($child, $node);
|
||||
break;
|
||||
case "Title":
|
||||
$node->children[] = Title::parse($child, $node);
|
||||
break;
|
||||
case "#comment":
|
||||
break;
|
||||
case "#text":
|
||||
|
37
src/Element/BookContent/Title.php
Normal file
37
src/Element/BookContent/Title.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace SukWs\Bookshelf\Element\BookContent;
|
||||
|
||||
use DOMNode;
|
||||
use Exception;
|
||||
|
||||
class Title {
|
||||
|
||||
private Chapter $parent;
|
||||
private string $title;
|
||||
|
||||
private function __construct (Chapter $parent, string $title) {
|
||||
$this->parent = $parent;
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function parse (DOMNode $xmlData, ?Chapter $parent): Title {
|
||||
if ($xmlData->hasAttributes())
|
||||
throw new Exception("Title need be clean with no any attr/children");
|
||||
if ($parent->getParent() != null)
|
||||
throw new Exception("Title must in root contents path");
|
||||
return new Title($parent, $xmlData->nodeValue);
|
||||
}
|
||||
|
||||
public function getParent (): Chapter {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getSummaryHtml (): string {
|
||||
return "<p class='menu-title'>$this->title</p>";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user