-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathwithBadgeGroup.tsx
More file actions
30 lines (25 loc) · 896 Bytes
/
withBadgeGroup.tsx
File metadata and controls
30 lines (25 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import BadgeGroup from '@node-core/ui-components/Common/BadgeGroup';
import type { FC } from 'react';
import Link from '#site/components/Link';
import { siteConfig } from '#site/next.json.mjs';
import { dateIsBetween } from '#site/util/date';
const WithBadgeGroup: FC<{ section: string }> = ({ section }) => {
const badge = siteConfig.websiteBadges[section];
if (badge && dateIsBetween(badge.startDate, badge.endDate)) {
return (
<BadgeGroup
as={Link}
badgeText={badge.title}
kind={badge.kind}
href={badge.link}
// Ensure that External Links have a target="_blank" and an arrow icon
// indicating that the link is external and should open in a new tab
target={/^https?:/.test(badge.link) ? '_blank' : undefined}
>
{badge.text}
</BadgeGroup>
);
}
return null;
};
export default WithBadgeGroup;