mirror of
https://github.com/liyunze-coding/coworking-website.git
synced 2026-11-06 13:13:34 +00:00
fixed hamburger menu and edit link
This commit is contained in:
parent
e217e8ed92
commit
17e69a533d
4 changed files with 27 additions and 23 deletions
|
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
const currentUrl = Astro.url.pathname;
|
||||
const currentUrl = Astro.url.pathname.slice(0, -1) + ".md";
|
||||
---
|
||||
|
||||
<ul class="list-none text-sm">
|
||||
<li class="ml-[0.5rem] my-2">
|
||||
<a
|
||||
href={`https://github.com/liyunze-coding/coworking-website/edit/main/src/pages${currentUrl}.md`}
|
||||
href={`https://github.com/liyunze-coding/coworking-website/edit/main/src/pages${currentUrl}`}
|
||||
class="inline-flex gap-2 transition-colors duration-150 text-white hover:no-underline hover:text-blue-400"
|
||||
>
|
||||
<svg
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import SearchModal from "../ui/SearchModal.astro";
|
|||
<label
|
||||
class="hamburger-menu flex lg:hidden top-2 left-5"
|
||||
aria-label="Menu"
|
||||
transition:persist="hamburger-menu"
|
||||
>
|
||||
<input type="checkbox" aria-controls="navigation" />
|
||||
</label>
|
||||
|
|
@ -174,20 +175,22 @@ import SearchModal from "../ui/SearchModal.astro";
|
|||
</style>
|
||||
|
||||
<script is:inline>
|
||||
const verticalNavBar = document.getElementById("vertical-navbar");
|
||||
const hamburgerMenu = document.querySelector(".hamburger-menu input");
|
||||
|
||||
// JavaScript for toggling the menu
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// Close the menu when a link is clicked
|
||||
const navbarLinks = document.querySelectorAll("#vertical-navbar a");
|
||||
|
||||
navbarLinks.forEach((link) => {
|
||||
link.addEventListener("click", function () {
|
||||
if (verticalNavBar)
|
||||
verticalNavBar.classList.add("-translate-x-[200%]");
|
||||
if (verticalNavBar) hamburgerMenu.checked = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// comment this out if you don't want the search modal
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
document.addEventListener("astro:page-load", () => {
|
||||
// @ts-ignore
|
||||
new PagefindUI({
|
||||
element: "#searchModal-search",
|
||||
|
|
@ -197,5 +200,7 @@ import SearchModal from "../ui/SearchModal.astro";
|
|||
showImages: false,
|
||||
autofocus: false,
|
||||
});
|
||||
|
||||
if (hamburgerMenu) hamburgerMenu.checked = false;
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -164,9 +164,15 @@ const { showHome } = Astro.props;
|
|||
link.classList.add("text-gray-400");
|
||||
}
|
||||
});
|
||||
|
||||
// close dialog
|
||||
const dialog = document.querySelector("dialog");
|
||||
|
||||
if (dialog) {
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
// @ts-ignore
|
||||
new PagefindUI({
|
||||
element: "#vertical-search",
|
||||
|
|
@ -176,5 +182,4 @@ const { showHome } = Astro.props;
|
|||
showImages: false,
|
||||
autofocus: false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -50,11 +50,5 @@ const { id } = Astro.props;
|
|||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
id=`${id}-search`
|
||||
class="mt-2"
|
||||
transition:name="search"
|
||||
transition:persist
|
||||
>
|
||||
</div>
|
||||
<div id=`${id}-search` class="mt-2"></div>
|
||||
</dialog>
|
||||
|
|
|
|||
Loading…
Reference in a new issue