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 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} )}
- +
);