diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-03-04 01:46:45 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-03-04 01:46:45 +0300 |
commit | eeb84c5be16ecca239adae9c851bc0f7db0875a1 (patch) | |
tree | 9aa1056e643212e4c6133d90f38a1966f0fa35ca /model | |
parent | 917d2622aa5fe748c1cda914eae94c12be743c42 (diff) |
blog: support ToC
Diffstat (limited to 'model')
-rw-r--r-- | model/Post.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/model/Post.php b/model/Post.php index b0360ac..6f3f1ab 100644 --- a/model/Post.php +++ b/model/Post.php @@ -8,10 +8,12 @@ class Post extends Model { public string $title; public string $md; public string $html; + public string $tocHtml; public string $text; public int $ts; public int $updateTs; public bool $visible; + public bool $toc; public string $shortName; public function edit(array $data) { @@ -26,6 +28,10 @@ class Post extends Model { $data['text'] = markup::htmlToText($data['html']); } + if ((isset($data['toc']) && $data['toc']) || $this->toc) { + $data['toc_html'] = markup::toc($data['md']); + } + parent::edit($data); $this->updateImagePreviews(); } @@ -87,6 +93,10 @@ class Post extends Model { return $html; } + public function getToc(): ?string { + return $this->toc ? $this->tocHtml : null; + } + public function isUpdated(): bool { return $this->updateTs && $this->updateTs != $this->ts; } |