Skip to content

Commit

Permalink
rawBody and description cleaning. Need to add in regex
Browse files Browse the repository at this point in the history
  • Loading branch information
cade-conklin committed Sep 3, 2021
1 parent a166b64 commit d01e36c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gatsby-config.js
Expand Up @@ -455,17 +455,19 @@ module.exports = {
releaseDate(fromNow: false)
version
}
rawBody
}
}
}
`,
path: '/api/agent-release-notes.json',
serialize: ({ data }) =>
data.allMdx.nodes
.map(({ frontmatter }) => ({
.map(({ frontmatter, rawBody }) => ({
agent: getAgentName(frontmatter.subject),
date: frontmatter.releaseDate,
version: frontmatter.version,
description: cleanDescription(rawBody),
}))
.filter(({ date, agent }) => Boolean(date && agent)),
},
Expand Down
13 changes: 13 additions & 0 deletions src/utils/cleanDescription.js
@@ -0,0 +1,13 @@
/**
* @param {string} subject The release note "subject" in frontmatter
* @returns {string}
*/
const cleanDescription = (subject) => {
if (subject) {
const agentName = subject.replace(/(\r\\n|\\n|\r)/gm, '');
console.log(`PARTY TIME ${agentName}`);
return agentName;
}
};

module.exports = cleanDescription;

0 comments on commit d01e36c

Please sign in to comment.