From d01e36c6b963f24847740752ebcf6149135d49b5 Mon Sep 17 00:00:00 2001 From: Cade Conklin Date: Fri, 3 Sep 2021 16:36:08 -0700 Subject: [PATCH] rawBody and description cleaning. Need to add in regex --- gatsby-config.js | 4 +++- src/utils/cleanDescription.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/utils/cleanDescription.js diff --git a/gatsby-config.js b/gatsby-config.js index 15024d481a0..d878550434f 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -455,6 +455,7 @@ module.exports = { releaseDate(fromNow: false) version } + rawBody } } } @@ -462,10 +463,11 @@ module.exports = { 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)), }, diff --git a/src/utils/cleanDescription.js b/src/utils/cleanDescription.js new file mode 100644 index 00000000000..87a4dcb1eab --- /dev/null +++ b/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;