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
be231bd
commit 9305f83
Showing
15 changed files
with
116 additions
and
27 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 |
---|---|---|
@@ -1,7 +1,67 @@ | ||
--- | ||
import { Sprite } from "astro-icon" | ||
import { headerMenu as globalMenu } from "$data/headerMenu" | ||
import Socials from "./Socials.astro" | ||
import { getWikiItemsByCategory, WikiItem, postProcessWikiItem } from "$data/wiki" | ||
import { wikiCategories, WikiCategory } from "$data/wikiCategories" | ||
import { MarkdownInstance } from "$data/shared" | ||
// HACK: If we directly use MarkdownInstance<WikiItem>, Astro fails with a weird error | ||
type WikiItemInstance = MarkdownInstance<WikiItem> | ||
let rawWikiItems = [] | ||
let wikiItems = [] | ||
const url = new URL(Astro.request.url) | ||
const isWikiPage = url.pathname.includes("/wiki/") | ||
if (isWikiPage) { | ||
rawWikiItems = await Astro.glob<WikiItem>("/content/wiki/**/*.md") | ||
wikiItems = rawWikiItems.map((item) => ({ | ||
...item, | ||
frontmatter: postProcessWikiItem(item.frontmatter, item.file), | ||
})) | ||
} | ||
--- | ||
|
||
<div class="flex items-center sm:hidden"> | ||
<Sprite name="menu" size="26px" /> | ||
<div | ||
id="mobile-menu" | ||
class="fixed top-16 w-0 h-[calc(100%-4rem)] bg-baltic-sea overflow-y-auto overflow-x-hidden whitespace-nowrap" | ||
> | ||
<div class="p-3 flex flex-col gap-4"> | ||
{/* Global header menu */} | ||
{globalMenu.map((item) => ( | ||
<a class="header-link mr-0 text-xl bg-fin-lanka p-3" href={`/${item.toLowerCase()}/`}> | ||
{item} | ||
</a> | ||
))} | ||
</div> | ||
|
||
{/* Wiki-exclusive menu */} | ||
{isWikiPage && ( | ||
<div class="p-3 flex flex-col gap-3"> | ||
{wikiCategories.map((category: WikiCategory) => ( | ||
<> | ||
<span class="block font-bold text-sugar-cane">{category.title}</span> | ||
{getWikiItemsByCategory(wikiItems, category.key).map((item: WikiItemInstance) => ( | ||
<a | ||
class="header-link mr-0 text-lg bg-fin-lanka p-2" | ||
href={item.frontmatter.url.pathname} | ||
> | ||
{item.frontmatter.navigation.label || item.frontmatter.title} | ||
</a> | ||
))} | ||
</> | ||
))} | ||
</div> | ||
)} | ||
|
||
<Socials classes="mt-4 justify-center gap-7 mb-8" size={45} /> | ||
</div> | ||
|
||
{/* Since we disabled Tailwind's default border color system, we need to add a border to the menu manually */} | ||
<style> | ||
#mobile-menu { | ||
transition: width 0.1s linear; | ||
border-top: 3px solid #211f24; | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
import { Sprite } from "astro-icon" | ||
--- | ||
|
||
<div id="mobile-menu-toggle" class="flex items-center sm:hidden"> | ||
<Sprite name="menu" size="28px" /> | ||
</div> | ||
|
||
<script> | ||
const mobileMenuToggle = document.getElementById("mobile-menu-toggle") | ||
const mobileMenu = document.getElementById("mobile-menu") | ||
const body = document.body | ||
|
||
mobileMenuToggle.addEventListener("click", () => { | ||
mobileMenu.classList.toggle("w-full") | ||
body.classList.toggle("overflow-hidden") | ||
}) | ||
</script> |
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 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 @@ | ||
export const headerMenu = ["Projects", "Articles", "Wiki", "Catalogue"] as const |
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