-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add items to menu nav * fix code style * remove class * Update astro/components/SiteTitle.astro Co-authored-by: Yagiz Nizipli <[email protected]> * rename vars --------- Co-authored-by: Yagiz Nizipli <[email protected]>
- Loading branch information
1 parent
7299267
commit 983f433
Showing
2 changed files
with
79 additions
and
0 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,76 @@ | ||
--- | ||
import AstrolightSiteTitle from '@astrojs/starlight/components/SiteTitle.astro' | ||
import type { Props } from '@astrojs/starlight/props' | ||
const menuItems = [ | ||
{ name: 'Docs', href: '/introduction' }, | ||
{ name: 'Performance', href: '/performance' }, | ||
{ name: 'Playground', href: '/playground' }, | ||
] | ||
function pathsMatch(lhs: string, rhs: string): boolean { | ||
return rhs.includes(lhs) | ||
} | ||
--- | ||
|
||
<div> | ||
<AstrolightSiteTitle {...Astro.props} /> | ||
|
||
<div class="separator"></div> | ||
|
||
<div class="menu-items"> | ||
{ | ||
menuItems.map((menuItem) => ( | ||
<a | ||
href={menuItem.href} | ||
aria-current={ | ||
pathsMatch(encodeURI(menuItem.href), Astro.url.pathname) && "page" | ||
} | ||
> | ||
<span>{menuItem.name}</span> | ||
</a> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
|
||
<style> | ||
div { | ||
display: flex; | ||
gap: var(--sl-content-pad-x); | ||
align-items: center; | ||
} | ||
|
||
.separator { | ||
content: ""; | ||
height: 1.5rem; | ||
border-inline-end: 1px solid var(--sl-color-gray-4); | ||
} | ||
|
||
div a { | ||
text-decoration: none; | ||
color: var(--sl-color-white); | ||
font-size: var(--sl-text-base); | ||
font-weight: 500; | ||
} | ||
|
||
div a:hover { | ||
text-decoration: underline; | ||
color: var(--sl-color-text-accent); | ||
} | ||
|
||
[aria-current="page"], | ||
[aria-current="page"]:hover, | ||
[aria-current="page"]:focus { | ||
color: var(--sl-color-text-accent); | ||
} | ||
|
||
@media (min-width: 50rem) { | ||
.menu-items { | ||
display: flex; | ||
} | ||
.separator { | ||
display: block; | ||
} | ||
} | ||
</style> |