diff --git a/docs/LICENSE.md b/docs/LICENSE.md
new file mode 100644
index 0000000..924c5a3
--- /dev/null
+++ b/docs/LICENSE.md
@@ -0,0 +1,9 @@
+Copyright © 2026, Encode OSS Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
— 💖 —
\ No newline at end of file
diff --git a/docs/css/theme.css b/docs/css/theme.css
index a955299..f4fa055 100644
--- a/docs/css/theme.css
+++ b/docs/css/theme.css
@@ -44,7 +44,7 @@ main {
}
}
-@media (max-width: 800px) {
+@media (max-width: 750px) {
main {
padding: 1.5rem 1rem;
width: 100%;
@@ -53,6 +53,10 @@ main {
nav.toc {
display: none;
}
+
+ nav.site {
+ display: none;
+ }
}
/* Typography & spacing */
@@ -214,6 +218,45 @@ div.pagination a.next {
text-decoration: none;
}
+/* Navigation styling */
+
+nav.site {
+ position: fixed;
+ width : 20%;
+ padding: 2rem;
+ height: 100%;
+ overflow-y: scroll;
+}
+
+nav.site ul {
+ padding: 0;
+ margin: 0;
+}
+
+nav.site li {
+ padding: 0;
+ margin: 0.5rem 0;
+ display: block;
+}
+
+nav.site li a.active {
+ color: var(--link-color);
+}
+
+nav.site li a:hover {
+ color: var(--link-color);
+ text-decoration: none;
+}
+
+nav.site li a {
+ color: var(--muted-fg-color);
+}
+
+nav.site li a:hover {
+ color: var(--fg-color);
+ text-decoration: none;
+}
+
/* Table of contents styling */
nav.toc {
@@ -225,8 +268,6 @@ nav.toc {
overflow-y: scroll;
}
-/* Navigation styling */
-
nav.toc ul {
padding: 0;
margin: 0;
@@ -254,4 +295,6 @@ nav.toc li a {
nav.toc li a:hover {
color: var(--fg-color);
text-decoration: none;
-}
\ No newline at end of file
+}
+
+/* Navigation styling */
diff --git a/docs/templates/base.html b/docs/templates/base.html
index c7c500a..6228513 100644
--- a/docs/templates/base.html
+++ b/docs/templates/base.html
@@ -12,6 +12,9 @@
+
diff --git a/src/mkdocs/mkdocs.py b/src/mkdocs/mkdocs.py
index 33c0a7a..058d4ad 100644
--- a/src/mkdocs/mkdocs.py
+++ b/src/mkdocs/mkdocs.py
@@ -99,6 +99,26 @@ def __bool__(self):
return bool(self._items)
+class NavItem:
+ def __init__(self, title: str, page: Page):
+ self.title = title
+ self.page = page
+
+
+class Navigation:
+ def __init__(self, nav_items):
+ self._items = nav_items
+
+ def __iter__(self):
+ return iter(self._items)
+
+ @property
+ def html(self):
+ page = get_current_page()
+ t = jinja2.Template("""""")
+ return t.render({"nav": self, "page": page})
+
+
class PageContext:
def __init__(self, page, text, html, toc):
self.path = page.path
@@ -117,6 +137,7 @@ def title(self):
class MkDocs:
def __init__(self, input_dir):
self.site = self.load_site(input_dir)
+ self.nav = self.load_nav({}, self.site)
self.env = self.init_env(input_dir)
self.md = self.init_md()
self.base = self.env.get_template('base.html')
@@ -146,6 +167,29 @@ def load_site(self, input_dir):
statics = sorted(statics, key=lambda x: x.url)
return Site(pages, statics)
+ def load_nav(self, config, site):
+ if not config:
+ config = {"nav": [
+ {"title": page.path.stem, "path": str(page.path)}
+ for page in site.pages
+ ]}
+
+ nav_config = config.get('nav', [])
+ nav_config = nav_config if isinstance(nav_config, list) else []
+ nav_items = []
+ for item in nav_config:
+ if not isinstance(item, dict):
+ continue
+ path = item.get('path', '')
+ title = item.get('title', '')
+ if not path:
+ continue
+ if path:
+ page = site.lookup_by_path(path)
+ nav_item = NavItem(title, page)
+ nav_items.append(nav_item)
+ return Navigation(nav_items)
+
def init_env(self, input_dir) -> jinja2.Environment:
@jinja2.pass_context
def url(ctx, url_to):
@@ -191,6 +235,8 @@ def set_context(self, current_page):
_current_page.reset(token_page)
_site.reset(token_site)
+ # Commands...
+
def build(self, input, output):
input_dir = pathlib.Path(input)
output_dir = pathlib.Path(output)
@@ -206,7 +252,7 @@ def build(self, input, output):
html = self.md.reset().convert(text)
toc = TableOfContents(self.md)
page_ctx = PageContext(page=page, text=text, html=html, toc=toc)
- output = self.base.render(page=page_ctx)
+ output = self.base.render(page=page_ctx, nav=self.nav)
output_path.parent.mkdir(parents=True, exist_ok=True)
output_path.write_text(output)
@@ -239,7 +285,7 @@ def app(request):
html = self.md.reset().convert(text)
toc = TableOfContents(self.md)
page_ctx = PageContext(page=resource, text=text, html=html, toc=toc)
- output = self.base.render(page=page_ctx)
+ output = self.base.render(page=page_ctx, nav=self.nav)
return httpx.Response(200, content=httpx.HTML(output))
elif isinstance(resource, Static):
input_path = input_dir.joinpath(resource.path)
@@ -250,6 +296,8 @@ def app(request):
server.serve()
+# Command line client...
+
@click.group()
def cli():
if pathlib.Path('mkdocs.yml').exists():
diff --git a/src/mkdocs/theme/base.html b/src/mkdocs/theme/base.html
index df4f8b8..d647f36 100644
--- a/src/mkdocs/theme/base.html
+++ b/src/mkdocs/theme/base.html
@@ -43,19 +43,33 @@
@media (max-width: 1000px) {
main {
+ margin-left: 20%;
width: 75%;
}
nav.toc {
display: none;
}
+
+ nav.site {
+ width: 25%;
+ }
}
-@media (max-width: 600px) {
+@media (max-width: 750px) {
main {
+ margin-left: 0;
width: 100%;
padding: 1rem 1.5rem;
}
+
+ nav.toc {
+ display: none;
+ }
+
+ nav.site {
+ display: none;
+ }
}
/* Typography & spacing */
@@ -168,6 +182,14 @@
/* Table of contents styling */
+nav.site {
+ position: fixed;
+ width : 20%;
+ padding: 2rem;
+ height: 100%;
+ overflow-y: scroll;
+}
+
nav.toc {
position: fixed;
margin-left: 80%;
@@ -179,6 +201,35 @@
/* Navigation styling */
+nav.site ul {
+ padding: 0;
+ margin: 0;
+}
+
+nav.site li {
+ padding: 0;
+ margin: 0.5rem 0;
+ display: block;
+}
+
+nav.site li a.active {
+ color: var(--link-color);
+}
+
+nav.site li a:hover {
+ color: var(--link-color);
+ text-decoration: none;
+}
+
+nav.site li a {
+ color: var(--muted-fg-color);
+}
+
+nav.site li a:hover {
+ color: var(--fg-color);
+ text-decoration: none;
+}
+
nav.toc ul {
padding: 0;
margin: 0;
@@ -210,6 +261,11 @@
+ {% if nav %}
+
+ {% endif %}
{% if page.toc %}