AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix: implement client-side tag filtering to support static deployment
yoma333335a2a728
diff --git a/apps/site/src/pages/blog.astro b/apps/site/src/pages/blog.astroindex 829a1281..78dd8708 100644--- a/apps/site/src/pages/blog.astro+++ b/apps/site/src/pages/blog.astro@@ -5,15 +5,7 @@ import Layout from "@/layouts/Layout.astro";import { getFormattedDate } from "@/utils/all";import { getLocalizedPath, getSiteLocale, siteCopy } from "@/i18n";-const selectedTag = Astro.url.searchParams.get("tag");--const entries = (await getCollection("blog", ({ data }) => {- const isNotDraft = !data.draft;- if (selectedTag) {- return isNotDraft && data.tags && data.tags.includes(selectedTag);- }- return isNotDraft;-})).sort(+const entries = (await getCollection("blog", ({ data }) => !data.draft)).sort((a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(),);@@ -44,49 +36,33 @@ const blogJsonLd = {</h1></div>- <!-- 标签筛选工具条 -->+ <!-- 标签筛选工具条 (全部默认为普通态,通过客户端 Script 激活) --><div class="flex flex-wrap gap-2 mb-10 select-none"><ahref={getLocalizedPath(locale, "/blog")}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- !selectedTag- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="all"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">{copy.tagAll}</a><ahref={`${getLocalizedPath(locale, "/blog")}?tag=migration`}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- selectedTag === "migration"- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="migration"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">🏷️ {copy.tagMigration}</a><ahref={`${getLocalizedPath(locale, "/blog")}?tag=mcp`}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- selectedTag === "mcp"- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="mcp"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">🤖 {copy.tagMcp}</a><ahref={`${getLocalizedPath(locale, "/blog")}?tag=self-hosted`}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- selectedTag === "self-hosted"- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="self-hosted"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">☁️ {copy.tagSelfHosted}</a>@@ -97,6 +73,8 @@ const blogJsonLd = {entries.map((entry) => (<ahref={`/blog/${entry.slug}`}+ data-blog-card+ data-tags={entry.data.tags ? entry.data.tags.join(",") : ""}class="group rounded-2xl border border-slate-200 bg-white p-6 shadow-sm transition hover:-translate-y-0.5 hover:border-brand-border hover:shadow-lg"><div class="flex flex-wrap items-center gap-3 text-sm text-slate-500">@@ -119,3 +97,48 @@ const blogJsonLd = {</main></Container></Layout>++<script is:inline>+ (() => {+ const updateFilters = () => {+ const urlParams = new URLSearchParams(window.location.search);+ const tag = urlParams.get("tag");++ // 1. 更新按钮激活状态+ const buttons = document.querySelectorAll("[data-tag-btn]");+ const activeClasses = ["text-brand", "bg-brand/5", "border-brand-border/40", "font-semibold", "shadow-sm"];+ const inactiveClasses = ["text-slate-600", "bg-slate-50", "border-slate-200", "hover:bg-slate-100", "hover:text-slate-900"];++ buttons.forEach((btn) => {+ const btnTag = btn.getAttribute("data-tag-btn");+ const isActive = (!tag && btnTag === "all") || (tag && btnTag === tag);++ if (isActive) {+ btn.classList.remove(...inactiveClasses);+ btn.classList.add(...activeClasses);+ } else {+ btn.classList.remove(...activeClasses);+ btn.classList.add(...inactiveClasses);+ }+ });++ // 2. 隐藏或显示对应的文章卡片+ const cards = document.querySelectorAll("[data-blog-card]");+ cards.forEach((card) => {+ if (!tag) {+ card.classList.remove("hidden");+ return;+ }+ const cardTags = (card.getAttribute("data-tags") || "").split(",");+ if (cardTags.includes(tag)) {+ card.classList.remove("hidden");+ } else {+ card.classList.add("hidden");+ }+ });+ };++ updateFilters();+ window.addEventListener("popstate", updateFilters);+ })();+</script>diff --git a/apps/site/src/pages/en/blog.astro b/apps/site/src/pages/en/blog.astroindex 7cbda99b..ac72bf32 100644--- a/apps/site/src/pages/en/blog.astro+++ b/apps/site/src/pages/en/blog.astro@@ -5,24 +5,16 @@ import Container from "@/components/container.astro";import { getFormattedDate } from "@/utils/all";import { getLocalizedPath, getSiteLocale, siteCopy } from "@/i18n";-const selectedTag = Astro.url.searchParams.get("tag");--const entries = (await getCollection("blog_en", ({ data }) => {- const isNotDraft = !data.draft;- if (selectedTag) {- return isNotDraft && data.tags && data.tags.includes(selectedTag);- }- return isNotDraft;-})).sort(+const entries = (await getCollection("blog_en", ({ data }) => !data.draft)).sort((a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(),);-const blogDescription =- "English EdgeEver notes about Cloudflare self-hosting, Evernote migration, product updates, and AI Agent workflows.";-const locale = getSiteLocale(Astro.url.pathname);const copy = siteCopy[locale].nav;+const blogDescription =+ "English EdgeEver notes about Cloudflare self-hosting, Evernote migration, product updates, and AI Agent workflows.";+const blogUrl = new URL(Astro.url.pathname, Astro.site).toString();const blogJsonLd = {"@context": "https://schema.org",@@ -38,51 +30,35 @@ const blogJsonLd = {<Container><section class="mx-auto max-w-4xl py-16 md:py-24"><p class="text-sm font-semibold text-brand-text">EdgeEver Blog</p>- <h1 class="mt-3 text-4xl font-bold tracking-tight text-slate-950 md:text-5xl">Blog</h1>+ <h1 class="mt-3 text-4xl font-bold tracking-tight text-slate-900 md:text-5xl">Blog</h1>- <!-- 标签筛选工具条 -->+ <!-- 标签筛选工具条 (全部默认为普通态,通过客户端 Script 激活) --><div class="flex flex-wrap gap-2 mt-8 mb-10 select-none"><ahref={getLocalizedPath(locale, "/blog")}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- !selectedTag- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="all"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">{copy.tagAll}</a><ahref={`${getLocalizedPath(locale, "/blog")}?tag=migration`}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- selectedTag === "migration"- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="migration"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">🏷️ {copy.tagMigration}</a><ahref={`${getLocalizedPath(locale, "/blog")}?tag=mcp`}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- selectedTag === "mcp"- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="mcp"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">🤖 {copy.tagMcp}</a><ahref={`${getLocalizedPath(locale, "/blog")}?tag=self-hosted`}- class:list={[- "px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer",- selectedTag === "self-hosted"- ? "text-brand bg-brand/5 border-brand-border/40 font-semibold shadow-sm"- : "text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900"- ]}+ data-tag-btn="self-hosted"+ class="px-4 py-1.5 text-xs font-medium border rounded-full transition-all duration-200 cursor-pointer text-slate-600 bg-slate-50 border-slate-200 hover:bg-slate-100 hover:text-slate-900">☁️ {copy.tagSelfHosted}</a>@@ -93,6 +69,8 @@ const blogJsonLd = {entries.map((entry) => (<ahref={`/en/blog/${entry.slug}`}+ data-blog-card+ data-tags={entry.data.tags ? entry.data.tags.join(",") : ""}class="group rounded-2xl border border-slate-200 bg-white p-6 shadow-sm transition hover:-translate-y-0.5 hover:border-brand-border hover:shadow-lg"><div class="flex flex-wrap items-center gap-3 text-sm text-slate-500">@@ -115,3 +93,48 @@ const blogJsonLd = {</section></Container></Layout>++<script is:inline>+ (() => {+ const updateFilters = () => {+ const urlParams = new URLSearchParams(window.location.search);+ const tag = urlParams.get("tag");++ // 1. 更新按钮激活状态+ const buttons = document.querySelectorAll("[data-tag-btn]");+ const activeClasses = ["text-brand", "bg-brand/5", "border-brand-border/40", "font-semibold", "shadow-sm"];+ const inactiveClasses = ["text-slate-600", "bg-slate-50", "border-slate-200", "hover:bg-slate-100", "hover:text-slate-900"];++ buttons.forEach((btn) => {+ const btnTag = btn.getAttribute("data-tag-btn");+ const isActive = (!tag && btnTag === "all") || (tag && btnTag === tag);++ if (isActive) {+ btn.classList.remove(...inactiveClasses);+ btn.classList.add(...activeClasses);+ } else {+ btn.classList.remove(...activeClasses);+ btn.classList.add(...inactiveClasses);+ }+ });++ // 2. 隐藏或显示对应的文章卡片+ const cards = document.querySelectorAll("[data-blog-card]");+ cards.forEach((card) => {+ if (!tag) {+ card.classList.remove("hidden");+ return;+ }+ const cardTags = (card.getAttribute("data-tags") || "").split(",");+ if (cardTags.includes(tag)) {+ card.classList.remove("hidden");+ } else {+ card.classList.add("hidden");+ }+ });+ };++ updateFilters();+ window.addEventListener("popstate", updateFilters);+ })();+</script>