-
Notifications
You must be signed in to change notification settings - Fork 119
feat(landing): rebuild the docs shell for reading and split the tree into sections #935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,33 +1,38 @@ | ||
| --- | ||
| // Previous / next across the whole docs tree in sidebar order, so reading | ||
| // straight through follows the same path the sidebar shows. | ||
| // Previous / next within the current section, in sidebar order, so reading | ||
| // straight through follows the same path the sidebar shows and stops where | ||
| // the section does. | ||
| import { getDocGroups } from "../../lib/docs-order"; | ||
| import { sectionForGroup } from "../../lib/docs-nav"; | ||
|
|
||
| interface Props { | ||
| currentSlug: string; | ||
| } | ||
|
|
||
| const { currentSlug } = Astro.props; | ||
|
|
||
| const flat = (await getDocGroups()).flatMap((g) => g.docs); | ||
| const groups = await getDocGroups(); | ||
| const current = groups.flatMap((g) => g.docs).find((d) => d.id === currentSlug); | ||
| const section = current ? sectionForGroup(current.data.group) : null; | ||
| const flat = groups.filter((g) => section && sectionForGroup(g.group).id === section.id).flatMap((g) => g.docs); | ||
| const i = flat.findIndex((d) => d.id === currentSlug); | ||
| const prev = i > 0 ? flat[i - 1] : null; | ||
| const next = i >= 0 && i < flat.length - 1 ? flat[i + 1] : null; | ||
| --- | ||
|
|
||
| <nav class="mt-12 pt-8 border-t border-border grid grid-cols-1 sm:grid-cols-2 gap-3" aria-label="Page navigation"> | ||
| <nav class="mt-14 grid grid-cols-1 gap-3 border-t border-border pt-8 sm:grid-cols-2" aria-label="Page navigation"> | ||
| {prev ? ( | ||
| <a href={`/docs/${prev.id}`} class="group rounded-lg border border-border p-4 hover:bg-bg-elevated transition-colors"> | ||
| <span class="block text-[10px] text-fg-muted uppercase tracking-wider">Previous</span> | ||
| <span class="block text-sm text-fg mt-1">{prev.data.title}</span> | ||
| <span class="block text-[11px] text-fg-muted mt-0.5">{prev.data.group}</span> | ||
| <span class="block font-mono text-[10px] uppercase tracking-[0.14em] text-fg-muted">Previous</span> | ||
| <span class="mt-1.5 block text-[14px] font-medium text-fg">{prev.data.title}</span> | ||
| <span class="mt-0.5 block text-[12px] text-fg-muted">{prev.data.group}</span> | ||
| </a> | ||
| ) : <div />} | ||
| {next ? ( | ||
| <a href={`/docs/${next.id}`} class="group rounded-lg border border-border p-4 hover:bg-bg-elevated transition-colors sm:text-right"> | ||
| <span class="block text-[10px] text-fg-muted uppercase tracking-wider">Next</span> | ||
| <span class="block text-sm text-fg mt-1">{next.data.title}</span> | ||
| <span class="block text-[11px] text-fg-muted mt-0.5">{next.data.group}</span> | ||
| <span class="block font-mono text-[10px] uppercase tracking-[0.14em] text-fg-muted">Next</span> | ||
| <span class="mt-1.5 block text-[14px] font-medium text-fg">{next.data.title}</span> | ||
| <span class="mt-0.5 block text-[12px] text-fg-muted">{next.data.group}</span> | ||
| </a> | ||
| ) : <div />} | ||
| </nav> |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| --- | ||
| // Section strip under the docs header: the same four sections the sidebar | ||
| // switcher shows, as tabs with the group glyphs. Both read getDocSections so | ||
| // the two never disagree about where a page lives. | ||
| import DocsCategoryIcon from "./DocsCategoryIcon.astro"; | ||
| import { getDocSections } from "../../lib/docs-order"; | ||
|
|
||
| interface Props { | ||
| currentSlug: string; | ||
| } | ||
| const { currentSlug } = Astro.props; | ||
| const sections = await getDocSections(currentSlug); | ||
| --- | ||
|
|
||
| <nav class="docs-section-nav flex h-10 items-stretch gap-1 overflow-x-auto border-t border-border/60 px-2 sm:px-4" aria-label="Documentation sections"> | ||
| {sections.map((s) => ( | ||
| <a | ||
| href={s.href} | ||
| aria-current={s.active ? "page" : undefined} | ||
| class:list={[ | ||
| "group relative flex items-center gap-2 whitespace-nowrap px-2.5 text-[13px] transition-colors", | ||
| s.active ? "font-medium text-fg" : "text-fg-muted hover:text-fg", | ||
| ]} | ||
| > | ||
| <DocsCategoryIcon | ||
| name={s.icon} | ||
| class:list={["h-3.5 w-3.5 shrink-0 transition-colors", s.active ? "text-primary" : "text-fg-muted/70 group-hover:text-fg-muted"]} | ||
| /> | ||
| <span>{s.label}</span> | ||
| <span | ||
| class:list={[ | ||
| "pointer-events-none absolute inset-x-1 -bottom-px h-0.5 bg-primary transition-opacity", | ||
| s.active ? "opacity-100" : "opacity-0 group-hover:opacity-30", | ||
| ]} | ||
| ></span> | ||
| </a> | ||
| ))} | ||
| </nav> | ||
|
|
||
| <style> | ||
| /* Scrolls sideways on phones; the scrollbar would only add a second rule. */ | ||
| .docs-section-nav { | ||
| scrollbar-width: none; | ||
| } | ||
| .docs-section-nav::-webkit-scrollbar { | ||
| display: none; | ||
| } | ||
| </style> | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use a location state for a section link.
When the current document is not the first document in its section,
s.activeis true buts.hrefpoints to a different page.aria-current="page"then reports that different link as the current page. Use"location"for the active section, or omitaria-current.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents