-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
116 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
{ | ||
"Get Started": [ | ||
"/docs/get-started/introduction/", | ||
"/docs/get-started/installation/" | ||
], | ||
"Tutorials": [ | ||
"/docs/tutorials/build-x/" | ||
], | ||
"Guides": [ | ||
"/docs/guides/migrate-from-z/" | ||
"main": [ | ||
{ | ||
"text": "Get Started", | ||
"header": true | ||
}, | ||
{ | ||
"text": "Installation", | ||
"link": "/docs/get-started/installation" | ||
}, | ||
{ | ||
"text": "Introduction", | ||
"link": "/docs/get-started/introduction" | ||
}, | ||
{ | ||
"text": "Guides", | ||
"header": true | ||
}, | ||
{ | ||
"text": "Migrate from Z", | ||
"link": "/docs/guides/migrate-from-z" | ||
}, | ||
{ | ||
"text": "Tutorials", | ||
"header": true | ||
}, | ||
{ | ||
"text": "Build X", | ||
"link": "/docs/tutorials/build-x" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 6 additions & 19 deletions
25
src/layouts/DocsSingle.astro → src/layouts/DocSingle.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,58 @@ | ||
--- | ||
import { SIDEBAR } from '@/config/config.ts'; | ||
import docs from "@/config/docs.json"; | ||
const { currentPage } = Astro.props; | ||
const currentPageMatch = currentPage.slice(1); | ||
const isCurrentPage = (item) => { | ||
if (item.link) { | ||
return item.link.includes(currentPageMatch); | ||
} | ||
return false; | ||
if (item.link) { | ||
return item.link.includes(currentPageMatch); | ||
} | ||
return false; | ||
}; | ||
const getLinkClasses = (link) => { | ||
const baseClasses = "block py-2 px-6 my-1 transition-colors border-l hover:border-slate-400 text-slate-500 hover:text-slate-900" | ||
const baseClasses = | ||
"block py-2 px-6 my-1 transition-colors border-l hover:border-slate-400 text-slate-500 hover:text-slate-900"; | ||
if (isCurrentPage(link)) { | ||
return baseClasses + " border-slate-500 text-slate-900"; | ||
} else { | ||
return baseClasses; | ||
} | ||
if (isCurrentPage(link)) { | ||
return baseClasses + " border-slate-500 text-slate-900"; | ||
} else { | ||
return baseClasses; | ||
} | ||
}; | ||
export interface doc_data { | ||
text: string; | ||
header?: boolean; | ||
link?: string; | ||
} | ||
const { main }: { main: doc_data[] } = docs; | ||
--- | ||
<aside title="Site Navigation"> | ||
<!-- <Debug content={navigation} /> --> | ||
<nav aria-labelledby="grid-left" class="w-64 p-4 border-r"> | ||
<ul> | ||
{SIDEBAR.map(item => (item.header ? | ||
<h2 class="mt-4 font-semibold text-slate-700">{item.text}</h2> : | ||
<li class={getLinkClasses(item)}> | ||
<a href={item.link}>{item.text}</a> | ||
</li>))} | ||
</ul> | ||
</nav> | ||
</aside> | ||
|
||
<nav aria-labelledby="grid-left" class="w-64 border-r"> | ||
<div class="px-4 py-16"> | ||
<ul> | ||
{ | ||
main.map((item) => | ||
item.header ? ( | ||
<h3 class="font-semibold text-slate-700">{item.text}</h3> | ||
) : ( | ||
<li class={getLinkClasses(item)}> | ||
<a href={item.link}>{item.text}</a> | ||
</li> | ||
), | ||
) | ||
} | ||
</ul> | ||
</div> | ||
</nav> | ||
|
||
<script is:inline> | ||
window.addEventListener('DOMContentLoaded', (event) => { | ||
var target = document.querySelector('[aria-current="page"]'); | ||
if (target && target.offsetTop > window.innerHeight - 100) { | ||
document.querySelector('.nav-groups').scrollTop = target.offsetTop; | ||
} | ||
}); | ||
window.addEventListener("DOMContentLoaded", (event) => { | ||
var target = document.querySelector('[aria-current="page"]'); | ||
if (target && target.offsetTop > window.innerHeight - 100) { | ||
document.querySelector(".nav-groups").scrollTop = target.offsetTop; | ||
} | ||
}); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,33 @@ | ||
--- | ||
const { headings } = Astro.props; | ||
const { headings } = Astro.props; | ||
--- | ||
<!-- <ul class="flex flex-col gap-4 mt-24"> | ||
{ headings.map(({ slug, text }) => { | ||
return ( | ||
<li class="text-slate-400 hover:text-slate-800"> | ||
#<a href={`#${slug}`}>{text}</a> | ||
</li> | ||
) | ||
}) } | ||
</ul> --> | ||
|
||
<nav aria-labelledby="grid-right"> | ||
<div class="px-8"> | ||
<div id="_anchor" class="fixed top-0 py-24 px-4"> | ||
<h1 class="dark:text-white text-xl my-4">On This Page</h1> | ||
{headings.map((heading) => { | ||
let Heading: any = `h${heading.depth}`; | ||
let className = `peer border-l-2 border-l-zinc-400 dark:border-l-zinc-700 ` | ||
switch (heading.depth) { | ||
case 2: | ||
className += `pl-2`; | ||
break; | ||
case 3: | ||
className += `pl-4`; | ||
break; | ||
case 4: | ||
className += `pl-6`; | ||
break; | ||
case 5: | ||
className += `pl-8`; | ||
break; | ||
case 6: | ||
className += `pl-10`; | ||
break; | ||
default: | ||
break; | ||
} | ||
return <Heading class={className}> | ||
<a href={`#${heading.slug}`} class="block py-1 text-zinc-600 dark:text-zinc-400 hover:text-green-600 dark:hover:text-zinc-300 transition-colors"> | ||
{heading.text} | ||
</a> | ||
</Heading> | ||
})} | ||
</div> | ||
</div> | ||
<div class="px-4 py-16"> | ||
<h3 class="dark:text-white mb-4">On This Page</h3> | ||
{ | ||
headings.map((heading) => { | ||
let className = `peer border-l-2 border-l-zinc-400 dark:border-l-zinc-700 `; | ||
const sizeAndIndent = { | ||
1: `pl-0 text-3xl`, | ||
2: `pl-2 text-2xl`, | ||
3: `pl-4 text-xl`, | ||
4: `pl-6 text-lg`, | ||
5: `pl-8 text-base`, | ||
6: `pl-10 text-sm`, | ||
}; | ||
className += sizeAndIndent[heading.depth] || ""; | ||
return ( | ||
<p class={className}> | ||
<a | ||
href={`#${heading.slug}`} | ||
class="block py-1 text-zinc-600 dark:text-zinc-400 hover:text-green-600 dark:hover:text-zinc-300 transition-colors" | ||
> | ||
{heading.text} | ||
</a> | ||
</p> | ||
); | ||
}) | ||
} | ||
</div> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters