feat: small improvements to navbar
This commit is contained in:
parent
97f10385ba
commit
e510ab0d03
@ -4,12 +4,20 @@ import { splitAndLast } from "../utils";
|
|||||||
|
|
||||||
const hierarchy: Hierarchy = Astro.props.hierarchy;
|
const hierarchy: Hierarchy = Astro.props.hierarchy;
|
||||||
|
|
||||||
export function postComparison(a: Post, b: Post): number {
|
function postComparison(a: Post, b: Post): number {
|
||||||
const s1 = splitAndLast(a.url);
|
const s1 = splitAndLast(a.url);
|
||||||
const s2 = splitAndLast(b.url);
|
const s2 = splitAndLast(b.url);
|
||||||
|
|
||||||
return s1 > s2 ? 0 : 1;
|
return s1 > s2 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function appendSlash(s: string): string {
|
||||||
|
if (s.endsWith("/")) {
|
||||||
|
return s;
|
||||||
|
} else {
|
||||||
|
return s + "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -19,7 +27,7 @@ export function postComparison(a: Post, b: Post): number {
|
|||||||
{folderPost !== null ? (
|
{folderPost !== null ? (
|
||||||
<a
|
<a
|
||||||
class="inline-block rounded-2xl w-full hover:bg-neutral-200 dark:hover:bg-neutral-800 transition-colors px-3 py-2"
|
class="inline-block rounded-2xl w-full hover:bg-neutral-200 dark:hover:bg-neutral-800 transition-colors px-3 py-2"
|
||||||
href={folderPost.url}
|
href={appendSlash(folderPost.url)}
|
||||||
>
|
>
|
||||||
{splitAndLast(folderPost.url)}
|
{splitAndLast(folderPost.url)}
|
||||||
</a>
|
</a>
|
||||||
@ -42,7 +50,7 @@ export function postComparison(a: Post, b: Post): number {
|
|||||||
hierarchy.posts.sort(postComparison).map((p) => (
|
hierarchy.posts.sort(postComparison).map((p) => (
|
||||||
<a
|
<a
|
||||||
class="inline-block rounded-2xl w-full hover:bg-neutral-200 dark:hover:bg-neutral-800 transition-colors px-3 py-2"
|
class="inline-block rounded-2xl w-full hover:bg-neutral-200 dark:hover:bg-neutral-800 transition-colors px-3 py-2"
|
||||||
href={p.url}
|
href={appendSlash(p.url)}
|
||||||
>
|
>
|
||||||
{splitAndLast(p.url)}
|
{splitAndLast(p.url)}
|
||||||
</a>
|
</a>
|
||||||
|
@ -26,19 +26,19 @@ const { showSidebarButton = true } = Astro.props;
|
|||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="/learn/"
|
href="/learn/"
|
||||||
class="hidden lg:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
||||||
>
|
>
|
||||||
Learn
|
Learn
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="/spec/"
|
href="/spec/"
|
||||||
class="hidden lg:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
||||||
>
|
>
|
||||||
Language spec
|
Language spec
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="/api/std/"
|
href="/api/std/"
|
||||||
class="hidden lg:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
class="hidden sm:inline-block px-4 font-display font-bold-text-xl hover:underline"
|
||||||
>
|
>
|
||||||
std reference
|
std reference
|
||||||
</a>
|
</a>
|
||||||
@ -56,7 +56,6 @@ const { showSidebarButton = true } = Astro.props;
|
|||||||
}
|
}
|
||||||
|
|
||||||
sidebarToggle.addEventListener("click", () => {
|
sidebarToggle.addEventListener("click", () => {
|
||||||
console.log(":D");
|
|
||||||
sidebar.classList.toggle("-translate-x-64");
|
sidebar.classList.toggle("-translate-x-64");
|
||||||
console.log(sidebar.classList.contains("-translate-x-64"));
|
console.log(sidebar.classList.contains("-translate-x-64"));
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user