feat: small improvements to navbar

master
Araozu 2024-08-26 12:10:22 -05:00
parent 97f10385ba
commit e510ab0d03
2 changed files with 14 additions and 7 deletions

View File

@ -4,12 +4,20 @@ import { splitAndLast } from "../utils";
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 s2 = splitAndLast(b.url);
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 ? (
<a
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)}
</a>
@ -42,7 +50,7 @@ export function postComparison(a: Post, b: Post): number {
hierarchy.posts.sort(postComparison).map((p) => (
<a
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)}
</a>

View File

@ -26,19 +26,19 @@ const { showSidebarButton = true } = Astro.props;
</a>
<a
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
</a>
<a
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
</a>
<a
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
</a>
@ -56,7 +56,6 @@ const { showSidebarButton = true } = Astro.props;
}
sidebarToggle.addEventListener("click", () => {
console.log(":D");
sidebar.classList.toggle("-translate-x-64");
console.log(sidebar.classList.contains("-translate-x-64"));
});