Skip to content

Commit fce00c0

Browse files
committed
f
1 parent fe19629 commit fce00c0

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

book.toml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,15 @@ title = "HackTricks"
88
create-missing = false
99
extra-watch-dirs = ["translations"]
1010

11-
[preprocessor.alerts]
12-
after = ["links"]
13-
14-
[preprocessor.reading-time]
15-
16-
[preprocessor.pagetoc]
17-
1811
[preprocessor.tabs]
1912

20-
[preprocessor.codename]
21-
2213
[preprocessor.hacktricks]
2314
command = "python3 ./hacktricks-preprocessor.py"
2415
env = "prod"
2516

2617
[output.html]
27-
additional-css = ["theme/pagetoc.css", "theme/tabs.css"]
18+
additional-css = ["theme/tabs.css"]
2819
additional-js = [
29-
"theme/pagetoc.js",
3020
"theme/tabs.js",
3121
"theme/ht_searcher.js",
3222
"theme/sponsor.js",

hacktricks-preprocessor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,13 @@ def iterate_chapters(sections):
166166
context, book = json.load(sys.stdin)
167167

168168
logger.debug(f"Context: {context}")
169+
logger.debug(f"Book keys: {book.keys()}")
170+
logger.debug(f"Book structure: {json.dumps(book, indent=2)[:500]}")
169171

170-
for chapter in iterate_chapters(book['sections']):
172+
# Handle both old (sections) and new (items) mdbook API
173+
book_items = book.get('sections') or book.get('items', [])
174+
175+
for chapter in iterate_chapters(book_items):
171176
logger.debug(f"Chapter: {chapter['path']}")
172177
current_chapter = chapter
173178
# regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endref[\s]*}}'

theme/index.hbs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -255,33 +255,33 @@
255255

256256
<nav class="nav-wrapper" aria-label="Page navigation">
257257
<!-- Mobile navigation buttons -->
258-
{{#previous}}
259-
<a rel="prev" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
258+
{{#if previous}}
259+
<a rel="prev" href="{{ path_to_root }}{{previous.path}}" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
260260
<i class="fa fa-angle-left"></i>
261261
</a>
262-
{{/previous}}
262+
{{/if}}
263263

264-
{{#next}}
265-
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
264+
{{#if next}}
265+
<a rel="next prefetch" href="{{ path_to_root }}{{next.path}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
266266
<i class="fa fa-angle-right"></i>
267267
</a>
268-
{{/next}}
268+
{{/if}}
269269

270270
<div style="clear: both"></div>
271271
</nav>
272272

273273
<nav class="nav-wide-wrapper" aria-label="Page navigation">
274-
{{#previous}}
275-
<a rel="prev" href="{{ path_to_root }}{{link}}" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
276-
<i class="fa fa-angle-left"></i><span style="font-size: medium; align-self: center; margin-left: 10px;">{{title}}</span>
274+
{{#if previous}}
275+
<a rel="prev" href="{{ path_to_root }}{{previous.path}}" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
276+
<i class="fa fa-angle-left"></i><span style="font-size: medium; align-self: center; margin-left: 10px;">{{previous.name}}</span>
277277
</a>
278-
{{/previous}}
278+
{{/if}}
279279

280-
{{#next}}
281-
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
282-
<span style="font-size: medium; align-self: center; margin-right: 10px;">{{title}}</span><i class="fa fa-angle-right"></i>
280+
{{#if next}}
281+
<a rel="next prefetch" href="{{ path_to_root }}{{next.path}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
282+
<span style="font-size: medium; align-self: center; margin-right: 10px;">{{next.name}}</span><i class="fa fa-angle-right"></i>
283283
</a>
284-
{{/next}}
284+
{{/if}}
285285
</nav>
286286
</div>
287287

0 commit comments

Comments
 (0)