From a845ea0f8ccbd902a898b992bb950fce9880235a Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Sun, 3 Oct 2021 01:24:22 +0200 Subject: [PATCH 1/2] 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} )}
- +
); From f0baf4bc3499f90bc2b6c569e03724070b314edb Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Mon, 4 Oct 2021 12:41:28 +0200 Subject: [PATCH 2/2] changelog entry --- changelog/items/bugs-fixed/fix-external-links-on-news-header.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/items/bugs-fixed/fix-external-links-on-news-header.md diff --git a/changelog/items/bugs-fixed/fix-external-links-on-news-header.md b/changelog/items/bugs-fixed/fix-external-links-on-news-header.md new file mode 100644 index 00000000..aa7c8c54 --- /dev/null +++ b/changelog/items/bugs-fixed/fix-external-links-on-news-header.md @@ -0,0 +1 @@ +- fixed the latest news link redirect in the news header