Better Toc and add gotop link
This commit is contained in:
parent
47f0f2e90c
commit
e47a6e4795
3 changed files with 16 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"erusev/parsedown": "^1.7",
|
"erusev/parsedown": "^1.7",
|
||||||
"keinos/parsedown-toc": "dev-master"
|
"hoegh/parsedown-toc": "^1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
css/main.css
13
css/main.css
|
@ -8,16 +8,20 @@
|
||||||
"menu main toc"
|
"menu main toc"
|
||||||
"footer footer footer";
|
"footer footer footer";
|
||||||
}
|
}
|
||||||
|
|
||||||
.toc>* {
|
|
||||||
position: fixed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.backTop {
|
||||||
|
content: "test";
|
||||||
|
}
|
||||||
|
|
||||||
.menu {
|
.menu {
|
||||||
grid-area: menu;
|
grid-area: menu;
|
||||||
font-size: .9rem;
|
font-size: .9rem;
|
||||||
|
@ -30,6 +34,7 @@ body {
|
||||||
.toc {
|
.toc {
|
||||||
grid-area: toc;
|
grid-area: toc;
|
||||||
font-size: .9rem;
|
font-size: .9rem;
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toc ul {
|
.toc ul {
|
||||||
|
|
|
@ -15,7 +15,7 @@ if (isset($file)) {
|
||||||
|
|
||||||
if (empty($file) || !file_exists('content/' . urldecode($dir) . '/' . urldecode($file) . '.md')) {
|
if (empty($file) || !file_exists('content/' . urldecode($dir) . '/' . urldecode($file) . '.md')) {
|
||||||
$dir = '';
|
$dir = '';
|
||||||
if(file_exists('content/index.md')){
|
if (file_exists('content/index.md')) {
|
||||||
$file = 'index';
|
$file = 'index';
|
||||||
} else {
|
} else {
|
||||||
$file = 'default';
|
$file = 'default';
|
||||||
|
@ -26,13 +26,16 @@ if (empty($file) || !file_exists('content/' . urldecode($dir) . '/' . urldecode(
|
||||||
$Parsedown = new ParsedownToc();
|
$Parsedown = new ParsedownToc();
|
||||||
|
|
||||||
$content = file_get_contents('content/' . urldecode($dir) . '/' . urldecode($file) . '.md');
|
$content = file_get_contents('content/' . urldecode($dir) . '/' . urldecode($file) . '.md');
|
||||||
|
$options = array('selectors' => array('h2', 'h3'));
|
||||||
|
|
||||||
$Parsedown = new ParsedownToc();
|
$Parsedown = new ParsedownToc($options);
|
||||||
$body = $Parsedown->text($content);
|
$body = $Parsedown->text($content);
|
||||||
$toc = $Parsedown->contentsList();
|
$toc = $Parsedown->contentsList();
|
||||||
|
|
||||||
$body = str_replace("[ ]", '<input type="checkbox" disabled>', $body);
|
$body = str_replace("[ ]", '<input type="checkbox" disabled>', $body);
|
||||||
$body = str_replace("[x]", '<input type="checkbox" checked disabled>', $body);
|
$body = str_replace("[x]", '<input type="checkbox" checked disabled>', $body);
|
||||||
|
$body = str_replace("</h2>", ' <a href="#" class="backTop">⬆️</a></h2>', $body);
|
||||||
|
$body = str_replace("</h3>", ' <a href="#" class="backTop">⬆️</a></h3>', $body);
|
||||||
|
|
||||||
require 'tpl/header.html';
|
require 'tpl/header.html';
|
||||||
require 'tpl/aside.html';
|
require 'tpl/aside.html';
|
||||||
|
|
Loading…
Reference in a new issue