From 20602dab6be9709b044421e5f121c1ea9ca013d5 Mon Sep 17 00:00:00 2001 From: mahuan <1007409254@qq.com> Date: Wed, 5 Mar 2025 19:39:30 +0800 Subject: [PATCH 1/3] feat: keywords support for tutorials; Release notes Change --- src/components/PageHeader.astro | 29 ++++++++++++++++++- src/pages/cn/blog/tags/[slug]/index.astro | 2 +- .../cn/blog/tags/[slug]/page/[page].astro | 3 +- src/pages/cn/tutorials/[slug].astro | 4 +-- src/pages/en/blog/tags/[slug]/index.astro | 2 +- .../en/blog/tags/[slug]/page/[page].astro | 2 +- src/pages/en/tutorials/[slug].astro | 4 ++- src/pages/ja/blog/tags/[slug]/index.astro | 2 +- .../ja/blog/tags/[slug]/page/[page].astro | 2 +- src/pages/ja/tutorials/[slug].astro | 2 +- src/utils/index.ts | 2 +- 11 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/components/PageHeader.astro b/src/components/PageHeader.astro index d61e3a4..85f09c8 100644 --- a/src/components/PageHeader.astro +++ b/src/components/PageHeader.astro @@ -10,13 +10,14 @@ interface TabProps { interface Props { title: string; showRSS?: boolean; + showTimeline?: boolean; description?: any; tabs?: TabProps[]; breadcrumb?: TabProps[]; className?: string; } -const { showRSS, className, title, description, tabs, breadcrumb } = Astro.props; +const { showRSS, showTimeline = false, className, title, description, tabs, breadcrumb } = Astro.props; const items = tabs || breadcrumb || []; --- @@ -53,6 +54,32 @@ const items = tabs || breadcrumb || []; </a> ) } + { + showTimeline && ( + <a + href={ + Astro.url.pathname.startsWith("/cn/") + ? "/cn/blog/timeline" + : Astro.url.pathname.startsWith("/ja/") + ? "/ja/blog/timeline" + : "/en/blog/timeline" + } + > + <svg + style="zoom: 1.5; margin-top: -3px;" + xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-arrow-repeat" + viewBox="0 0 16 16" + > + <path d="M11.534 7h3.932a.25.25 0 0 1 .192.41l-1.966 2.36a.25.25 0 0 1-.384 0l-1.966-2.36a.25.25 0 0 1 .192-.41zm-11 2h3.932a.25.25 0 0 0 .192-.41L2.692 6.23a.25.25 0 0 0-.384 0L.342 8.59A.25.25 0 0 0 .534 9z"/> + <path fill-rule="evenodd" d="M8 3c-1.552 0-2.94.707-3.857 1.818a.5.5 0 1 1-.771-.636A6.002 6.002 0 0 1 13.917 7H12.9A5.002 5.002 0 0 0 8 3zM3.1 9a5.002 5.002 0 0 0 8.757 2.182.5.5 0 1 1 .771.636A6.002 6.002 0 0 1 2.083 9H3.1z"/> + </svg> + </a> + ) + } </h1> <p class="para-desc mx-auto text-muted"> {description} diff --git a/src/pages/cn/blog/tags/[slug]/index.astro b/src/pages/cn/blog/tags/[slug]/index.astro index 6c41eb3..1b10b0e 100644 --- a/src/pages/cn/blog/tags/[slug]/index.astro +++ b/src/pages/cn/blog/tags/[slug]/index.astro @@ -60,7 +60,7 @@ const socialLinks = [ --- <Layout title={title} description={description} keywords={keywords}> - <PageHeader showRSS title={title} description={description} breadcrumb={tabs}> + <PageHeader showRSS showTimeline={slug === 'release-notes'} title={title} description={description} breadcrumb={tabs}> </PageHeader> <section class="section"> <div class="container"> diff --git a/src/pages/cn/blog/tags/[slug]/page/[page].astro b/src/pages/cn/blog/tags/[slug]/page/[page].astro index 7ed444b..ad3d269 100644 --- a/src/pages/cn/blog/tags/[slug]/page/[page].astro +++ b/src/pages/cn/blog/tags/[slug]/page/[page].astro @@ -56,7 +56,7 @@ const socialLinks = [ --- <Layout title={title} description={description} keywords={keywords}> - <PageHeader showRSS title={title} description={description} breadcrumb={tabs}></PageHeader> + <PageHeader showRSS showTimeline={slug === 'release-notes'} title={title} description={description} breadcrumb={tabs}></PageHeader> <section class="section"> <div class="container"> <div class="row"> @@ -91,6 +91,7 @@ const socialLinks = [ basepath={basepath} socialLinks={socialLinks} lang="cn" + description={description} /> </div> diff --git a/src/pages/cn/tutorials/[slug].astro b/src/pages/cn/tutorials/[slug].astro index fabf821..043a2c8 100644 --- a/src/pages/cn/tutorials/[slug].astro +++ b/src/pages/cn/tutorials/[slug].astro @@ -14,8 +14,8 @@ if (!data) { return new Response("Not found", { status: 404 }); } const title = data.title_cn || data.title; -const keywords = (data.tags || []) - .map((tag: any) => tag.title_cn || tag.title) +const keywords = (data.keywords || []) + .map((keywords: any) => keywords.title_cn || keywords.title) .join(","); const description = data.description_cn || data.description; const basepath = "/cn/tutorials"; diff --git a/src/pages/en/blog/tags/[slug]/index.astro b/src/pages/en/blog/tags/[slug]/index.astro index 75173d1..00f6107 100644 --- a/src/pages/en/blog/tags/[slug]/index.astro +++ b/src/pages/en/blog/tags/[slug]/index.astro @@ -50,7 +50,7 @@ const socialLinks = [ --- <Layout title={title} description={description} keywords={keywords}> - <PageHeader showRSS title={title} description={description} breadcrumb={tabs}> + <PageHeader showRSS showTimeline={slug === 'release-notes'} title={title} description={description} breadcrumb={tabs}> </PageHeader> <section class="section"> <div class="container"> diff --git a/src/pages/en/blog/tags/[slug]/page/[page].astro b/src/pages/en/blog/tags/[slug]/page/[page].astro index f3fe4f8..8a4094a 100644 --- a/src/pages/en/blog/tags/[slug]/page/[page].astro +++ b/src/pages/en/blog/tags/[slug]/page/[page].astro @@ -50,7 +50,7 @@ const socialLinks = [ --- <Layout title={title} description={description} keywords={keywords}> - <PageHeader showRSS title={title} description={description} breadcrumb={tabs}> + <PageHeader showRSS showTimeline={slug === 'release-notes'} title={title} description={description} breadcrumb={tabs}></PageHeader> </PageHeader> <section class="section"> <div class="container"> diff --git a/src/pages/en/tutorials/[slug].astro b/src/pages/en/tutorials/[slug].astro index 72ff4cf..dc46026 100644 --- a/src/pages/en/tutorials/[slug].astro +++ b/src/pages/en/tutorials/[slug].astro @@ -14,7 +14,9 @@ if (!data) { return new Response("Not found", { status: 404 }); } const title = data.title; -const keywords = (data.tags || []).map((tag: any) => tag.title).join(","); +const keywords = (data.tags || []) + .map((keywords: any) => keywords.title) + .join(","); const description = data.description; const basepath = "/en/tutorials"; const tabs = [ diff --git a/src/pages/ja/blog/tags/[slug]/index.astro b/src/pages/ja/blog/tags/[slug]/index.astro index 1f148c7..d43af7c 100644 --- a/src/pages/ja/blog/tags/[slug]/index.astro +++ b/src/pages/ja/blog/tags/[slug]/index.astro @@ -49,7 +49,7 @@ const socialLinks = [ --- <Layout title={title} description={description} keywords={keywords}> - <PageHeader showRSS title={title} description={description} breadcrumb={tabs}> + <PageHeader showRSS showTimeline={slug === 'release-notes'} title={title} description={description} breadcrumb={tabs}> </PageHeader> <section class="section"> <div class="container"> diff --git a/src/pages/ja/blog/tags/[slug]/page/[page].astro b/src/pages/ja/blog/tags/[slug]/page/[page].astro index ddd2cce..75312f2 100644 --- a/src/pages/ja/blog/tags/[slug]/page/[page].astro +++ b/src/pages/ja/blog/tags/[slug]/page/[page].astro @@ -51,7 +51,7 @@ const socialLinks = [ --- <Layout title={title} description={description} keywords={keywords}> - <PageHeader showRSS title={title} description={description} breadcrumb={tabs}></PageHeader> + <PageHeader showRSS showTimeline={slug === 'release-notes'} title={title} description={description} breadcrumb={tabs}></PageHeader> <section class="section"> <div class="container"> <div class="row"> diff --git a/src/pages/ja/tutorials/[slug].astro b/src/pages/ja/tutorials/[slug].astro index dbac885..d73d6ab 100644 --- a/src/pages/ja/tutorials/[slug].astro +++ b/src/pages/ja/tutorials/[slug].astro @@ -14,7 +14,7 @@ if (!data) { return new Response("Not found", { status: 404 }); } const title = data.title_ja || data.title; -const keywords = (data.tags || []).map((tag: any) => tag.title_ja || tag.title).join(","); +const keywords = (data.keywords || []).map((keywords: any) => keywords.title_ja || keywords.title).join(","); const description = data.description_ja || data.description; const basepath = "/ja/tutorials"; const tabs = [ diff --git a/src/utils/index.ts b/src/utils/index.ts index 1b82569..b49660d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -301,7 +301,7 @@ export async function getTutorialArticle(slug?: string, locale = 'en') { if (!slug) { return {}; } - const res = await fetch(`${baseURL}tutorialArticles:get?appends=serials&filter[slug]=${slug}&token=${token}`); + const res = await fetch(`${baseURL}tutorialArticles:get?appends=serials,keywords&filter[slug]=${slug}&token=${token}`); const body = await res.json(); const data = body.data || {}; if (!data.id) { From 886bf676902aa042c05ebc39df2fb7cf56c5125c Mon Sep 17 00:00:00 2001 From: mahuan <1007409254@qq.com> Date: Wed, 5 Mar 2025 19:41:26 +0800 Subject: [PATCH 2/3] feat: show timeline switcher --- src/pages/cn/blog/timeline.astro | 1 + src/pages/en/blog/timeline.astro | 1 + src/pages/ja/blog/timeline.astro | 1 + 3 files changed, 3 insertions(+) diff --git a/src/pages/cn/blog/timeline.astro b/src/pages/cn/blog/timeline.astro index 5ce2327..af4f8d4 100644 --- a/src/pages/cn/blog/timeline.astro +++ b/src/pages/cn/blog/timeline.astro @@ -59,6 +59,7 @@ const tabs = [ <Layout title="发布日志" description={description}> <PageHeader title="发布日志" + showTimeline={true} description={description} breadcrumb={tabs} /> diff --git a/src/pages/en/blog/timeline.astro b/src/pages/en/blog/timeline.astro index cfe7c44..ebfbdc0 100644 --- a/src/pages/en/blog/timeline.astro +++ b/src/pages/en/blog/timeline.astro @@ -59,6 +59,7 @@ const tabs = [ <Layout title="Release Notes" description={description}> <PageHeader title="Release Notes" + showTimeline={true} description={description} breadcrumb={tabs} /> diff --git a/src/pages/ja/blog/timeline.astro b/src/pages/ja/blog/timeline.astro index d683567..92048b8 100644 --- a/src/pages/ja/blog/timeline.astro +++ b/src/pages/ja/blog/timeline.astro @@ -59,6 +59,7 @@ const tabs = [ <Layout title="リリースノート " description={description}> <PageHeader title="リリースノート " + showTimeline={true} description={description} breadcrumb={tabs} /> From d9cad109f1008eb792c605c713315cff794e351d Mon Sep 17 00:00:00 2001 From: mahuan <1007409254@qq.com> Date: Wed, 5 Mar 2025 19:43:21 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat=EF=BC=9A=20timeline=20switch=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PageHeader.astro | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/PageHeader.astro b/src/components/PageHeader.astro index 85f09c8..92b27bd 100644 --- a/src/components/PageHeader.astro +++ b/src/components/PageHeader.astro @@ -58,11 +58,17 @@ const items = tabs || breadcrumb || []; showTimeline && ( <a href={ - Astro.url.pathname.startsWith("/cn/") - ? "/cn/blog/timeline" - : Astro.url.pathname.startsWith("/ja/") - ? "/ja/blog/timeline" - : "/en/blog/timeline" + Astro.url.pathname.includes("/blog/timeline") + ? Astro.url.pathname.startsWith("/cn/") + ? "/cn/blog/tags/release-notes" + : Astro.url.pathname.startsWith("/ja/") + ? "/ja/blog/tags/release-notes" + : "/en/blog/tags/release-notes" + : Astro.url.pathname.startsWith("/cn/") + ? "/cn/blog/timeline" + : Astro.url.pathname.startsWith("/ja/") + ? "/ja/blog/timeline" + : "/en/blog/timeline" } > <svg