Skip to content

Commit

Permalink
add props validation for LinkSection, apply linting
Browse files Browse the repository at this point in the history
  • Loading branch information
naomatheus committed Aug 18, 2023
1 parent 3deb5fb commit 12d8606
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/pages/glossary.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,13 @@ const LinkSection = ({ node }) => {
<div>
{parts.map((part, index) => {
// return first element of parts array which matches node.id
// eslint-disable-next-line
const link = node.links?.find(link => link.id === part)

// if a part matches link.id, replace that part with an ExternalLink, and reconcat as node.definition
if (link) {
return (
// eslint-disable-next-line
<span>
<ExternalLink
key={index}
Expand All @@ -307,6 +309,19 @@ const LinkSection = ({ node }) => {
)
}

LinkSection.propTypes = {
node: PropTypes.shape({
definition: PropTypes.string.isRequired,
links: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
})
),
}).isRequired,
}

export const query = graphql`
{
allGlossaryJson {
Expand Down

0 comments on commit 12d8606

Please sign in to comment.