Skip to content

Commit

Permalink
feat: add link to toc to docs on mobile (jsr-io#55)
Browse files Browse the repository at this point in the history
The TOC being under the content in docs is fine, but it now means it's
not clear how to get there from the top of the page. This commit adds a
link to the top of the page that when clicked will scroll you to the
table of contents.
  • Loading branch information
lucacasonato authored Mar 1, 2024
1 parent e4d58bd commit 7622f77
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/routes/docs/[...id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function PackagePage({ data }: PageProps<Data, State>) {
<div class="grid grid-cols-1 md:grid-cols-10">
<nav class="pb-10 md:border-r-1.5 md:col-span-3 lg:col-span-2 order-2 md:order-1 border-t-1.5 border-cyan-900 md:border-t-0 md:border-slate-300 pt-4 md:pt-0">
<div>
<p class="text-xl font-semibold">Docs</p>
<p class="text-xl font-semibold" id="sidebar">Docs</p>
</div>

{Array.from(groups.entries()).map(([group, files]) => (
Expand All @@ -63,6 +63,9 @@ export default function PackagePage({ data }: PageProps<Data, State>) {
</nav>

<div class="md:col-span-7 mb-12 md:px-6 lg:px-8 order-1 md:order-2">
<p class="text-sm mb-6 -mt-2 md:hidden">
<a href="#sidebar" class="link">View table of contents</a>
</p>
<h1 class="text-4xl lg:text-5xl lg:leading-[1.1] text-balance font-medium mb-8 text-gray-900">
{data.title}
</h1>
Expand Down

0 comments on commit 7622f77

Please sign in to comment.