Skip to content

Commit

Permalink
Add nav for docs pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kepano committed Mar 15, 2024
1 parent 96c59fa commit 3ffda29
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<iframe
width="100%"
height="100%"
src="/spec/1.0">
src="/spec/1.0?hidenav=true">
</iframe>
</node>

Expand Down
15 changes: 10 additions & 5 deletions .layouts/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
{% include head.html %}
<body>

<nav>
<a href="/"><img width="120" height="44" src="/logo.svg" alt="JSON Feed" /></a>
</nav>

<hr>
{% include nav.html %}

<div class="page">
{{ content }}
</div>

<script>
document.addEventListener("DOMContentLoaded", function() {
const urlParams = new URLSearchParams(window.location.search);
const hideNav = urlParams.get('hidenav');
if(hideNav === 'true') {
document.body.classList.add('hidenav');
}
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const links = document.querySelectorAll('a');
links.forEach(link => {
Expand Down
10 changes: 10 additions & 0 deletions .layouts/nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div id="navbar">
<nav>
<a href="/" id="logo"><img width="120" height="44" src="/logo.svg" alt="JSON Feed" /></a>
<a href="/spec/1.0" class="link">Spec</a>
<a href="/docs/apps" class="link">Apps</a>
<a href="https://github.com/obsidianmd/jsoncanvas" class="link">GitHub</a>
</nav>

<hr>
</div>
11 changes: 0 additions & 11 deletions .layouts/node.html

This file was deleted.

2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defaults:
- scope:
path: "spec/**/*.md"
values:
layout: "node"
layout: "docs"
- scope:
path: "docs/**/*.md"
values:
Expand Down
19 changes: 19 additions & 0 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ nav {
padding: 24px 36px;
max-width: 48em;
margin: 0 auto;
display: flex;
align-items: center;
gap: 4px;
}
nav #logo {
flex-grow: 1;
}
nav .link {
color: var(--color-ax-1);
text-decoration: none;
padding: 0.25em 0.5em;
border-radius: 6px;
}
nav .link:hover {
color: var(--color-bg-1);
background-color: var(--color-ax-1);
}
.hidenav #navbar {
display: none;
}

/* Specific nodes */
Expand Down

0 comments on commit 3ffda29

Please sign in to comment.