From a845ea0f8ccbd902a898b992bb950fce9880235a Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Sun, 3 Oct 2021 01:24:22 +0200 Subject: [PATCH] fixed the latest news link redirect in the news header --- .../src/components/NewsHeader/NewsHeader.js | 6 ++-- packages/website/src/pages/news.js | 29 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/website/src/components/NewsHeader/NewsHeader.js b/packages/website/src/components/NewsHeader/NewsHeader.js index cdbbffb7..17161f26 100644 --- a/packages/website/src/components/NewsHeader/NewsHeader.js +++ b/packages/website/src/components/NewsHeader/NewsHeader.js @@ -12,6 +12,7 @@ const NewsHeader = () => { id frontmatter { title + external } fields { slug @@ -26,8 +27,9 @@ const NewsHeader = () => { if (!latestNews) return null; // no news - const title = latestNews.node.frontmatter.title; - const link = { to: latestNews.node.fields.slug }; + const { frontmatter, fields } = latestNews.node; + const { title, external } = frontmatter; + const link = external ? { href: external } : { to: fields.slug }; return (
diff --git a/packages/website/src/pages/news.js b/packages/website/src/pages/news.js index 7c0f7719..f3b9a220 100644 --- a/packages/website/src/pages/news.js +++ b/packages/website/src/pages/news.js @@ -6,39 +6,36 @@ import { NewsSummary } from "../components/News"; import Link from "../components/Link"; import Seo from "../components/seo"; -const NewsCard = ({ ...props }) => { - const linkProps = { to: !props.frontmatter.external && props.fields.slug, href: props.frontmatter.external }; +const NewsCard = ({ frontmatter, fields }) => { + const { title, external, categories, description, thumbnail, avatar, author, date } = frontmatter; + const link = external ? { href: external } : { to: fields.slug }; return (
- - + + - {props.frontmatter.categories && ( + {categories && (
- {props.frontmatter.categories.map((category) => ( + {categories.map((category) => ( ))}
)} - - {props.frontmatter.title} + + {title} - {props.frontmatter.description && ( - - {props.frontmatter.description} + {description && ( + + {description} )}
- +
);