Skip to content

Commit

Permalink
Use lot() Function
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Jun 5, 2024
1 parent 7fa7465 commit 54c89fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion about.page
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ color: '#f954ad'
image: /lot/x/t-o-c/index.png
author: Taufik Nurrohman
type: Markdown
version: 3.0.0
version: 3.0.1
...

This extension automatically displays a table of contents on top of the page content. It detects the presence of heading
Expand Down
16 changes: 8 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php

namespace x\t_o_c {
function get() {
\extract($GLOBALS, \EXTR_SKIP);
\class_exists("\\Asset") && $state->is('page') && \Asset::set(__DIR__ . \D . 'index' . (\defined("\\TEST") && \TEST ? '.' : '.min.') . 'css', 10);
}
function page__content($content) {
\extract($GLOBALS, \EXTR_SKIP);
\extract(\lot(), \EXTR_SKIP);
return $state->is('page') ? \x\t_o_c\to\content($content, $state->x->{'t-o-c'}->min ?? 2) : $content;
}
\Hook::set('get', __NAMESPACE__ . "\\get", -1);
function route__page() {
\extract(\lot());
\class_exists("\\Asset") && $state->is('page') && \Asset::set(__DIR__ . \D . 'index' . (\defined("\\TEST") && \TEST ? '.' : '.min.') . 'css', 10);
}
\Hook::set('page.content', __NAMESPACE__ . "\\page__content", 2.3);
\Hook::set('route.page', __NAMESPACE__ . "\\route__page", -1);
}

namespace x\t_o_c\page__content {
function tree($content) {
\extract($GLOBALS, \EXTR_SKIP);
\extract(\lot(), \EXTR_SKIP);
$c = $state->x->{'t-o-c'};
if (
// Skip if not a page…
Expand Down Expand Up @@ -102,7 +102,7 @@ function tree(?string $content, int $min = 2): ?string {
]), 'role=heading'))) {
return null;
}
\extract($GLOBALS, \EXTR_SKIP);
\extract(\lot(), \EXTR_SKIP);
$count = [];
$current = $deep = $next = 0;
$out = "";
Expand Down

0 comments on commit 54c89fc

Please sign in to comment.