Skip to content

Commit

Permalink
Merge pull request #64 from scriptified/make-code-snippet-optional
Browse files Browse the repository at this point in the history
🐛 Make tip of the week snippet optional
  • Loading branch information
gupta-ji6 authored Aug 16, 2021
2 parents 79c3391 + bf42217 commit 9dfd5ef
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion interfaces/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion interfaces/tipOfTheWeek.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CodeSnippet from './codeSnippet';

export default interface TipOfTheWeek {
snippet: CodeSnippet;
snippet?: CodeSnippet;
desc: string;
sourceName: string;
sourceURL: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scriptified",
"version": "2.1.0",
"version": "2.1.1",
"private": true,
"license": "(MIT OR Apache-2.0)",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pages/issues/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function IssueComponent({ issueData }: { issueData: Issue }): JSX
<Text type="base" additionalStyles="py-4 relative z-10">
<Markdown>{issueData.tipOfTheWeek.desc}</Markdown>
</Text>
<CodeSnippet snippet={issueData.tipOfTheWeek.snippet} />
{issueData.tipOfTheWeek.snippet ? <CodeSnippet snippet={issueData.tipOfTheWeek.snippet} /> : null}
</IssueItem>
) : null}
{issueData?.articles !== null ? (
Expand Down
44 changes: 26 additions & 18 deletions scripts/issueEmailGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -121,6 +125,27 @@ ${article.description}
___
${
currentIssue.devOfTheWeek
? `# Dev of the Week
<img alt="${currentIssue.devOfTheWeek.name}" src="${getAssetURL(
currentIssue.id,
currentIssue.devOfTheWeek.profileImg
)}" style="width:200px;"/>
## ${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
Expand All @@ -137,23 +162,6 @@ ${tool.description}
___
# Dev of the Week
<img alt="${currentIssue.devOfTheWeek.name}" src="${getAssetURL(
currentIssue.id,
currentIssue.devOfTheWeek.profileImg
)}" style="width:200px;"/>
## ${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})
Expand Down

0 comments on commit 9dfd5ef

Please sign in to comment.