-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
2ab54f9
commit 64dc282
Showing
8 changed files
with
1,144 additions
and
105 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 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
import {} from "../utils/collections-entries" | ||
import { getCurrentArchetype } from "../utils/archetypes" | ||
import { getCollectionEntries } from "../utils/collections-entries" | ||
import HeaderNavLink from "./header/HeaderNavLink.astro" | ||
/** | ||
* Sidebar navigation, used to navigate between pages in the same collection. | ||
* Pages are fetched from the collection specified in the archetype, and grouped | ||
* by categories (folders in the collection, if any). | ||
*/ | ||
const archetype = getCurrentArchetype(Astro.url) | ||
const allEntries = await getCollectionEntries(archetype.collection) | ||
// Check if a link is the current page, used to apply the active class | ||
const isCurrentPage = (path: string) => { | ||
const currentPage = Astro.url.pathname.split("/")[2] | ||
return currentPage === path | ||
} | ||
--- | ||
|
||
<aside class="sidebar"> | ||
<h3>Getting started</h3> | ||
{ | ||
allEntries.map((doc) => ( | ||
<HeaderNavLink | ||
url={`/${archetype.path}/${doc.slug}`} | ||
isCurrent={isCurrentPage(doc.slug)} | ||
> | ||
{doc.data.title} | ||
</HeaderNavLink> | ||
)) | ||
} | ||
</aside> | ||
<style> | ||
.sidebar { | ||
display: flex; | ||
flex-direction: column; | ||
margin: 1.5rem; | ||
width: 250px; | ||
font-size: 0.9rem; | ||
} | ||
.sidebar a { | ||
display: flex; | ||
padding: 0.25rem 0.5rem; | ||
gap: 0.25rem; | ||
align-items: center; | ||
border-radius: 0.5rem; | ||
border: 1px solid transparent; | ||
text-decoration-line: none; | ||
} | ||
.sidebar a:hover { | ||
background-color: var(--color-lighter); | ||
} | ||
.sidebar a:active { | ||
color: var(--color-primary); | ||
} | ||
.sidebar h3 { | ||
font-size: 0.9rem; | ||
margin-left: 0.5rem; | ||
margin-bottom: 0.25rem; | ||
} | ||
</style> |
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
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.