Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

9.5 KB
Raw Blame
---
import Container from "@/components/container.astro";
import Dropdown from "./dropdown.astro";
import LanguageSwitcher from "./language-switcher.astro";
import { Icon } from "astro-icon/components";
import { getLocalizedPath, getSiteLocale, siteCopy } from "@/i18n";

const locale = getSiteLocale(Astro.url.pathname);
const copy = siteCopy[locale].nav;
const menuitems = [
  {
    title: copy.features,
    path: `${getLocalizedPath(locale, "/")}#features`,
  },
  {
    title: copy.bestPractices,
    path: getLocalizedPath(locale, "/guides/best-practices"),
  },
  {
    title: copy.deploy,
    children: [
      {
        title: copy.cloudflareDeploy,
        path: getLocalizedPath(locale, "/blog/ai-agent-deploy-cloudflare"),
      },
      {
        title: copy.dockerDeploy,
        path: getLocalizedPath(locale, "/docker-deploy"),
      },
    ],
  },
  {
    title: copy.guides,
    children: [
      {
        title: copy.selfHostedAlternative,
        path: getLocalizedPath(locale, "/self-hosted-evernote-alternative"),
      },
      {
        title: copy.evernoteMigration,
        path: getLocalizedPath(locale, "/blog/evernote-migration-guide"),
      },
      {
        title: copy.memosMigration,
        path: getLocalizedPath(locale, "/blog/memos-migration-guide"),
      },
      {
        title: copy.notionMigration,
        path: getLocalizedPath(locale, "/blog/notion-migration-guide"),
      },
      {
        title: copy.flomoMigration,
        path: getLocalizedPath(locale, "/blog/flomo-migration-guide"),
      },
      {
        title: copy.advancedPlay,
        path: getLocalizedPath(locale, "/guides/advanced-play"),
      },
    ],
  },
  {
    title: copy.blog,
    path: getLocalizedPath(locale, "/blog"),
  },
];
---

<Container>
  <header class="relative my-4 md:my-5 z-50">
    <div class="flex items-center justify-between">
      <!-- Logo Left -->
      <a href={getLocalizedPath(locale, "/")} class="flex items-center gap-2 text-lg select-none" aria-label={copy.homeAria}>
        <img src="/favicon.svg" alt="" class="h-8 w-8 shrink-0" aria-hidden="true" />
        <span>
          <span class="font-bold text-slate-800 tracking-tight text-base md:text-lg">Edge</span><span class="text-slate-500 text-base md:text-lg">Ever</span>
        </span>
      </a>

      <!-- Desktop Navigation Center -->
      <nav class="hidden lg:flex items-center gap-1">
        <ul class="flex items-center gap-1">
          {
            menuitems.map((item, index) => (
              <>
                {item.children && (
                  <Dropdown
                    title={item.title}
                    children={item.children}
                    lastItem={index === menuitems.length - 1}
                  />
                )}

                {!item.children && (
                  <li>
                    <a
                      href={item.path}
                      class="px-3.5 py-2 text-[13.5px] font-semibold text-slate-600 hover:text-emerald-700 hover:bg-slate-100/70 rounded-full transition-colors">
                      <span>{item.title}</span>
                    </a>
                  </li>
                )}
              </>
            ))
          }
        </ul>
      </nav>

      <!-- Actions & Hamburger Right -->
      <div class="flex items-center gap-2 sm:gap-3">
        <a
          href="https://www.producthunt.com/products/edgeever?launch=edgeever&utm_source=badge-featured&utm_medium=badge&utm_campaign=edgeever"
          target="_blank"
          rel="noopener"
          class="inline-flex items-center transition-transform duration-200 hover:-translate-y-0.5 shrink-0"
        >
          <img
            src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=edgeever&theme=neutral"
            alt="EdgeEver on Product Hunt"
            style="width: 120px; height: 26px;"
            width="120"
            height="26"
            loading="lazy"
          />
        </a>

        <!-- Desktop Only Items -->
        <div class="hidden lg:flex items-center gap-3">
          <LanguageSwitcher pathname={Astro.url.pathname} />
          <a
            href="https://github.com/tianma-if/edgeever"
            target="_blank"
            rel="noopener"
            class="inline-flex items-center gap-1.5 px-3.5 py-1.5 text-xs font-semibold text-slate-700 hover:text-slate-900 bg-white hover:bg-slate-50 border border-slate-200/90 hover:border-slate-300 rounded-full transition-all duration-200 shadow-2xs"
            aria-label="GitHub"
          >
            <Icon class="h-4 w-4 text-slate-800" name="bx:bxl-github" />
            <span>{copy.openSource}</span>
          </a>
        </div>

        <!-- Mobile Hamburger Toggle Button -->
        <button
          type="button"
          id="mobile-nav-toggle"
          aria-label="Toggle mobile menu"
          aria-controls="mobile-nav-menu"
          aria-expanded="false"
          class="lg:hidden min-h-11 min-w-11 p-2 rounded-xl border border-slate-200/80 bg-white/90 text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/40 focus-visible:ring-offset-2 transition-colors"
        >
          <svg id="hamburger-icon" class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
            <path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" />
          </svg>
          <svg id="close-icon" class="w-5 h-5 hidden" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
            <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
          </svg>
        </button>
      </div>
    </div>

    <!-- Mobile Navigation Drawer -->
    <div
      id="mobile-nav-menu"
      class="hidden lg:hidden mt-3 rounded-2xl border border-slate-200/90 bg-white/95 backdrop-blur-lg p-4 shadow-xl flex flex-col gap-3 transition-all"
    >
      <ul class="flex flex-col gap-1.5">
        {
          menuitems.map((item) => (
            <>
              {item.children ? (
                <li class="py-1">
                  <div class="px-3 py-1 text-xs font-bold text-slate-400 uppercase tracking-wider">{item.title}</div>
                  <div class="mt-1 flex flex-col gap-1 pl-2">
                    {item.children.map((child) => (
                      <a
                        href={child.path}
                        class="flex min-h-11 items-center px-3 py-2 text-xs font-semibold text-slate-700 hover:text-emerald-700 hover:bg-emerald-50/70 rounded-xl transition-colors"
                      >
                        {child.title}
                      </a>
                    ))}
                  </div>
                </li>
              ) : (
                <li>
                  <a
                    href={item.path}
                    class="flex min-h-11 items-center px-3 py-2 text-sm font-semibold text-slate-700 hover:text-emerald-700 hover:bg-emerald-50/70 rounded-xl transition-colors"
                  >
                    {item.title}
                  </a>
                </li>
              )}
            </>
          ))
        }
      </ul>

      <div class="pt-3 border-t border-slate-100 flex items-center justify-between gap-3">
        <div class="flex-1 min-w-0">
          <LanguageSwitcher pathname={Astro.url.pathname} compact />
        </div>
        <a
          href="https://github.com/tianma-if/edgeever"
          target="_blank"
          rel="noopener"
          class="inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold text-slate-700 bg-slate-50 hover:bg-slate-100 border border-slate-200 rounded-lg shrink-0 whitespace-nowrap"
          aria-label="GitHub"
        >
          <Icon class="h-4 w-4 text-slate-800 shrink-0" name="bx:bxl-github" />
          <span class="whitespace-nowrap shrink-0">{copy.openSource}</span>
        </a>
      </div>
    </div>
  </header>
</Container>

<script is:inline>
  (function () {
    document.addEventListener("click", function (e) {
      var toggleBtn = e.target && e.target.closest ? e.target.closest("#mobile-nav-toggle") : null;
      var menu = document.getElementById("mobile-nav-menu");
      var hamburgerIcon = document.getElementById("hamburger-icon");
      var closeIcon = document.getElementById("close-icon");

      function setMenuOpen(isOpen) {
        if (!menu || !toggleBtn) return;
        menu.classList.toggle("hidden", !isOpen);
        toggleBtn.setAttribute("aria-expanded", String(isOpen));
        if (hamburgerIcon) hamburgerIcon.classList.toggle("hidden", isOpen);
        if (closeIcon) closeIcon.classList.toggle("hidden", !isOpen);
      }

      if (toggleBtn && menu) {
        e.preventDefault();
        e.stopPropagation();
        var isHidden = menu.classList.contains("hidden");
        setMenuOpen(isHidden);
      }

      // Close all open <details> menus when clicking outside
      document.querySelectorAll("header details[open]").forEach(function (details) {
        if (!details.contains(e.target)) {
          details.removeAttribute("open");
        }
      });
    });

    document.addEventListener("keydown", function (e) {
      if (e.key !== "Escape") return;
      var toggleBtn = document.getElementById("mobile-nav-toggle");
      var menu = document.getElementById("mobile-nav-menu");
      if (!toggleBtn || !menu || menu.classList.contains("hidden")) return;

      menu.classList.add("hidden");
      toggleBtn.setAttribute("aria-expanded", "false");
      document.getElementById("hamburger-icon")?.classList.remove("hidden");
      document.getElementById("close-icon")?.classList.add("hidden");
      toggleBtn.focus();
    });
  })();
</script>