From 13ff2128f09da78da4c5fa76035abd72268ac3ce Mon Sep 17 00:00:00 2001 From: Visiky <736929286@qq.com> Date: Tue, 25 May 2021 09:50:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(announcement):=20=E5=85=AC=E5=91=8A?= =?UTF-8?q?=E5=88=A4=E7=A9=BA=E4=B8=8D=E5=B1=95=E7=A4=BA=20(#327)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(announcement): 公告判空不展示 * fix: 优化顶部公告展示逻辑,example 演示页不展示头部公告 * feat: 优化图表上新公告展示逻辑:大于4个新增 demo 或全部新增,则直接使用 category 作为代替 --- .../site/components/TopBanner.tsx | 12 ++- .../gatsby-theme-antv/site/layouts/layout.tsx | 15 ++-- .../site/templates/example.tsx | 88 ++++++++++++------- example/examples/radar/basic/demo/meta.json | 3 +- 4 files changed, 70 insertions(+), 48 deletions(-) diff --git a/@antv/gatsby-theme-antv/site/components/TopBanner.tsx b/@antv/gatsby-theme-antv/site/components/TopBanner.tsx index 87985a93..bef8b64a 100644 --- a/@antv/gatsby-theme-antv/site/components/TopBanner.tsx +++ b/@antv/gatsby-theme-antv/site/components/TopBanner.tsx @@ -20,18 +20,16 @@ const TopBanner: React.FC = ({ announcement }) => { return announcement ? announcement.en : ''; }, [announcement]); - return ( + const content = get(announcement, i18n.language); + + return content ? ( - {get(announcement, i18n.language)} - - } + message={{content}} bannerId={bannerId} localStorageId={BANNER_LOCALSTORAGE_KEY} style={{ borderRadius: 0, borderWidth: '1px 0' }} /> - ); + ) : null; }; export default TopBanner; diff --git a/@antv/gatsby-theme-antv/site/layouts/layout.tsx b/@antv/gatsby-theme-antv/site/layouts/layout.tsx index 3b2c73b8..1029b3ea 100644 --- a/@antv/gatsby-theme-antv/site/layouts/layout.tsx +++ b/@antv/gatsby-theme-antv/site/layouts/layout.tsx @@ -193,6 +193,10 @@ const Layout: React.FC = ({ children, location, footerProps }) => { } : {}; + const isExamplePage = + location.pathname.includes('/examples/') && + !location.pathname.endsWith('/gallery'); + return ( <> {rediectUrl && ( @@ -225,13 +229,12 @@ const Layout: React.FC = ({ children, location, footerProps }) => { ecosystems={ecosystems} {...logoProps} /> - {/* 首页不展示 头部 banner */} - {!isHomePage && } + {/* 首页和 example 演示页 不展示 头部 banner */} + {!isHomePage && !isExamplePage && ( + + )}
{children}
- {!( - location.pathname.includes('/examples/') && - !location.pathname.endsWith('/gallery') - ) && ( + {!isExamplePage && (