From: Dan Brown Date: Thu, 16 Mar 2023 04:22:01 +0000 (+0000) Subject: Added page export contents hack X-Git-Url: http://source.bookstackapp.com/hacks/commitdiff_plain/9843d55aae483317230bab7a91a401db4752a545 Added page export contents hack --- diff --git a/content/page-export-contents/exports/page.blade.php b/content/page-export-contents/exports/page.blade.php new file mode 100644 index 0000000..178d84d --- /dev/null +++ b/content/page-export-contents/exports/page.blade.php @@ -0,0 +1,34 @@ +@extends('layouts.export') + +@section('title', $page->name) + +@section('content') +
+ +

{{$page->name}}

+ @php + $toc = (new \BookStack\Entities\Tools\PageContent($page))->getNavigation($page->html); + @endphp + + @if(!empty($toc)) +
+
Page Contents
+ +
+ @endif + +
+ + {!! $page->renderedHTML ?? $page->html !!} +
+ +
+ +
+ @include('exports.parts.meta', ['entity' => $page]) +
+@endsection \ No newline at end of file diff --git a/content/page-export-contents/index.md b/content/page-export-contents/index.md new file mode 100644 index 0000000..ef67a68 --- /dev/null +++ b/content/page-export-contents/index.md @@ -0,0 +1,20 @@ ++++ +title = "Page Export Contents List" +author = "@ssddanbrown" +date = 2023-03-16T00:00:00Z +updated = 2023-03-16T00:00:00Z +tested = "v23.02.1" ++++ + +This hack uses the visual theme system to customize the page export template file, used for both PDF and HTML exports, to add a simple linked "Contents" list to the top of the file, generated from the headers within the document. + +#### Considerations + +- The "Page Contents" header is hardcoded in English. +- This contents list will not show page numbers for the PDF export. +- The contents will show when headers are used in page content. +- This hack uses internal an "PageContent" content class, and it's methods, which will likely change in future BookStack versions. + +#### Code + +{{}}