From 85b5a1f6ec778d4c14e31ba904b68251b9dc8ab2 Mon Sep 17 00:00:00 2001 From: Prateek Surana Date: Mon, 16 Aug 2021 13:21:29 +0530 Subject: [PATCH 1/3] :bug: Make tip of the week snippet optional --- interfaces/api.ts | 2 +- interfaces/tipOfTheWeek.ts | 2 +- lib/issues.ts | 2 +- pages/issues/[id].tsx | 2 +- scripts/issueEmailGenerator.js | 23 +++++------------------ 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/interfaces/api.ts b/interfaces/api.ts index 29ead83..cfde77e 100644 --- a/interfaces/api.ts +++ b/interfaces/api.ts @@ -28,7 +28,7 @@ export interface TipOfTheWeek { published_at: string; created_at: string; updated_at: string; - codeSnippet: CodeSnippet; + codeSnippet?: CodeSnippet; } export interface CodeSnippet { id: number; diff --git a/interfaces/tipOfTheWeek.ts b/interfaces/tipOfTheWeek.ts index 585216e..3d2418f 100644 --- a/interfaces/tipOfTheWeek.ts +++ b/interfaces/tipOfTheWeek.ts @@ -1,7 +1,7 @@ import CodeSnippet from './codeSnippet'; export default interface TipOfTheWeek { - snippet: CodeSnippet; + snippet?: CodeSnippet; desc: string; sourceName: string; sourceURL: string; diff --git a/lib/issues.ts b/lib/issues.ts index f64a12b..d9731aa 100644 --- a/lib/issues.ts +++ b/lib/issues.ts @@ -92,7 +92,7 @@ export function mapToIssue(issue: IssueAPIResponse): Issue { const tipOfTheWeek = issue.tipOfTheWeek !== null ? { - snippet: issue.tipOfTheWeek.codeSnippet, + snippet: issue.tipOfTheWeek.codeSnippet ?? null, desc: issue.tipOfTheWeek.description, sourceName: issue.tipOfTheWeek.sourceName, sourceURL: issue.tipOfTheWeek.sourceURL, diff --git a/pages/issues/[id].tsx b/pages/issues/[id].tsx index b0d8635..4485515 100644 --- a/pages/issues/[id].tsx +++ b/pages/issues/[id].tsx @@ -76,7 +76,7 @@ export default function IssueComponent({ issueData }: { issueData: Issue }): JSX {issueData.tipOfTheWeek.desc} - + {issueData.tipOfTheWeek.snippet ? : null} ) : null} {issueData?.articles !== null ? ( diff --git a/scripts/issueEmailGenerator.js b/scripts/issueEmailGenerator.js index 7724816..b718119 100644 --- a/scripts/issueEmailGenerator.js +++ b/scripts/issueEmailGenerator.js @@ -99,10 +99,14 @@ ${currentIssue.description} # Tip of the day ${currentIssue.tipOfTheWeek.description} +${ + currentIssue.tipOfTheWeek.codeSnippet && + ` \`\`\`${currentIssue.tipOfTheWeek.codeSnippet.language} ${currentIssue.tipOfTheWeek.codeSnippet.code} \`\`\` - +` +} ___ # Articles @@ -137,23 +141,6 @@ ${tool.description} ___ -# Dev of the Week - -${currentIssue.devOfTheWeek.name} - -## ${currentIssue.devOfTheWeek.name} -${currentIssue.devOfTheWeek.bio} - -${Object.keys(currentIssue.devOfTheWeek) - .filter(key => PROFILE_KEYS.includes(key) && currentIssue.devOfTheWeek[key] !== null) - .map(profile => `[${PROFILE_TYPES[profile]}](${currentIssue.devOfTheWeek[profile]})`) - .join(' | ')} - -___ - # Tech Talks [**${currentIssue.talks[0].title}**](${currentIssue.talks[0].url}) From 079ef0ca7f3db022d4633b25d050c5f93319cfbc Mon Sep 17 00:00:00 2001 From: Prateek Surana Date: Mon, 16 Aug 2021 13:27:15 +0530 Subject: [PATCH 2/3] :bookmark: v2.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28c484a..65b99e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scriptified", - "version": "2.1.0", + "version": "2.1.1", "private": true, "license": "(MIT OR Apache-2.0)", "scripts": { From bf42217befb2fbaced36848913812a5a93a8c4e4 Mon Sep 17 00:00:00 2001 From: Prateek Surana Date: Mon, 16 Aug 2021 22:04:44 +0530 Subject: [PATCH 3/3] :recycle: Conditionally handle dev of the week item in issue email generator --- scripts/issueEmailGenerator.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/issueEmailGenerator.js b/scripts/issueEmailGenerator.js index b718119..1349686 100644 --- a/scripts/issueEmailGenerator.js +++ b/scripts/issueEmailGenerator.js @@ -125,6 +125,27 @@ ${article.description} ___ +${ + currentIssue.devOfTheWeek + ? `# Dev of the Week + +${currentIssue.devOfTheWeek.name} + +## ${currentIssue.devOfTheWeek.name} +${currentIssue.devOfTheWeek.bio} + +${Object.keys(currentIssue.devOfTheWeek) + .filter(key => PROFILE_KEYS.includes(key) && currentIssue.devOfTheWeek[key] !== null) + .map(profile => `[${PROFILE_TYPES[profile]}](${currentIssue.devOfTheWeek[profile]})`) + .join(' | ')} + +___` + : '' +} + # Tools ${currentIssue.tools