Skip to content

Commit

Permalink
Fix Toc animation and homepage navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
timvink committed Sep 15, 2021
1 parent c0a86c6 commit 9b83cc7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions mkdocs_print_site_plugin/css/print-site.css
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ div.print-site-add-full-url section.print-page a[href^="http"]::after{
#print-site-page h6:target {
animation: highlight 1.5s ease;
}
#print-site-page .print-page:target h1 {
animation: highlight 1.5s ease;
}
@keyframes highlight {
from { color: orange; }
to { color: none; }
Expand Down
12 changes: 5 additions & 7 deletions mkdocs_print_site_plugin/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,19 @@ def get_toc_sidebar(self) -> TableOfContents:

for item in self._get_items():
if item.is_page:
# Take the first item of the page's ToC
# Which will be the heading 1
p = item.toc.items[0]
page_key = get_page_key(item.url)

toc.append(AnchorLink(title=p.title, id=f"{page_key}-{p.id}", level=0))
# navigate to top of page if page is homepage
if page_key == "index":
page_key = ""
toc.append(AnchorLink(title=item.title, id=f"{page_key}", level=0))
if item.is_section:

section_link = AnchorLink(title=item.title, id=f"section-{to_snake_case(item.title)}", level=0)

subpages = [p for p in item.children if p.is_page]
for page in subpages:
page_key = get_page_key(page.url)
p = page.toc.items[0]
section_link.children.append(AnchorLink(title=p.title, id=f"{page_key}-{p.id}", level=1))
section_link.children.append(AnchorLink(title=page.title, id=f"{page_key}", level=1))

toc.append(section_link)

Expand Down
2 changes: 1 addition & 1 deletion mkdocs_print_site_plugin/templates/cover_page.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<td>{{ config.copyright }}</td>
</tr>
{% endif %}
</dl>

</table>


Expand Down

0 comments on commit 9b83cc7

Please sign in to comment.