Skip to content

Commit

Permalink
Create section navigation that works across any level of nesting
Browse files Browse the repository at this point in the history
Signed-off-by: jmcshane <james.mcshane@superorbital.io>
  • Loading branch information
jmcshane committed Dec 20, 2024
1 parent 7bf8cd5 commit e940278
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
12 changes: 4 additions & 8 deletions docs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

import copy

from mkdocs_macros import fix_url


def define_env(env):
"""
This is the hook for defining variables, macros, and filters. See
Expand Down Expand Up @@ -58,11 +55,10 @@ def section_items(page, nav, config):

# Copy so we don't modify the original
child = copy.deepcopy(child)

# Have to fix the URL - see
# https://mkdocs-macros-plugin.readthedocs.io/en/latest/tips/#how-do-i-deal-with-relative-links-to-documentsimages
child.file.url = fix_url(child.url)


# Subsection nesting that works across any level of nesting
# Replaced mkdocs fix_url function
child.file.url = child.url.replace(page.url, "./")
siblings.append(child)

return siblings
2 changes: 1 addition & 1 deletion docs/overrides/partials/section-overview.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% for item in section_items(page, navigation, config) %}
### [{{ item.title }}]({{ item.url }})
### [{{ item.title }}]({{ item.file.url }})
{{ item.meta.description or '' }}
{% endfor %}
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mike==2.0.0
mike==2.1.3
mkdocs==1.5.3
mkdocs-awesome-pages-plugin==2.9.2
mkdocs-macros-plugin==1.0.5
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/serve-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ fi
# for local docs testing, we don't care what the remote branch looks like.
MIKE_OPTIONS+=(--ignore-remote-status)

mike set-default "${MIKE_OPTIONS[@]}" main
mike set-default "${MIKE_OPTIONS[@]}" --allow-undefined main
mike serve "${MIKE_OPTIONS[@]}"

0 comments on commit e940278

Please sign in to comment.