@@ -81,69 +81,108 @@ function getAssetURL(issueNumber: number, assetURL: string) {
8181}
8282
8383export function mapToIssue ( issue : IssueAPIResponse ) : Issue {
84- return {
85- meta : {
86- number : issue . id ,
87- title : issue . title ,
88- desc : issue . description ,
89- dateOfPublishing : issue . dateOfPublishing ,
90- imgURL : getOGImage ( issue . title , issue . id , issue . dateOfPublishing ) ,
91- } ,
92- tipOfTheWeek : {
93- snippet : issue . tipOfTheWeek . codeSnippet ,
94- desc : issue . tipOfTheWeek . description ,
95- sourceName : issue . tipOfTheWeek . sourceName ,
96- sourceURL : issue . tipOfTheWeek . sourceURL ,
97- } ,
98- articles : issue . articles . map ( article => ( {
99- title : article . title ,
100- desc : article . description ,
101- url : article . url ,
102- tags : article . tags . map ( tag => tag . name ) ,
103- author : oxfordComma ( article . authors . map ( author => author . Name ) ) ,
104- } ) ) ,
105- talks : issue . talks . map ( talk => ( {
106- title : talk . title ,
107- talkURL : talk . url ,
108- desc : talk . description ,
109- tags : talk . tags . map ( tag => tag . name ) ,
110- } ) ) ,
111- tools : issue . tools . map ( tool => ( {
112- title : tool . name ,
113- url : tool . url ,
114- logo : getAssetURL ( issue . id , tool . logo ) ,
115- desc : tool . description ,
116- tags : tool . tags . map ( tag => tag . name ) ,
117- author : oxfordComma ( tool . authors . map ( author => author . Name ) ) ,
118- } ) ) ,
119- devOfTheWeek : {
120- name : issue . devOfTheWeek . name ,
121- profileImg : getAssetURL ( issue . id , issue . devOfTheWeek . profileImg ) ,
122- bio : issue . devOfTheWeek . bio ,
123- profileLink : {
124- youtube : issue . devOfTheWeek . youtube ,
125- github : issue . devOfTheWeek . github ,
126- linkedin : issue . devOfTheWeek . linkedin ,
127- website : issue . devOfTheWeek . website ,
128- twitter : issue . devOfTheWeek . twitter ,
129- instagram : issue . devOfTheWeek . instagram ,
130- } ,
131- } ,
132- gif : {
133- gifURL : getAssetURL ( issue . id , issue . gif . gifURL ) ,
134- caption : issue . gif . caption ,
135- } ,
136- quiz : {
137- question : issue . quiz . question ,
138- answerId : issue . quiz . answerId ,
139- options : issue . quiz . Option . map ( option => ( {
140- description : option . description ,
141- id : option . option_id ,
142- text : option . text ,
143- } ) ) ,
144- snippet : issue . quiz . CodeSnippet ,
145- } ,
84+ const meta = {
85+ number : issue . id ,
86+ title : issue . title ,
87+ desc : issue . description ,
88+ dateOfPublishing : issue . dateOfPublishing ,
89+ imgURL : getOGImage ( issue . title , issue . id , issue . dateOfPublishing ) ,
14690 } ;
91+
92+ const tipOfTheWeek =
93+ issue . tipOfTheWeek !== null
94+ ? {
95+ snippet : issue . tipOfTheWeek . codeSnippet ,
96+ desc : issue . tipOfTheWeek . description ,
97+ sourceName : issue . tipOfTheWeek . sourceName ,
98+ sourceURL : issue . tipOfTheWeek . sourceURL ,
99+ }
100+ : null ;
101+
102+ const articles =
103+ issue ?. articles !== null
104+ ? issue ?. articles ?. map ( article => ( {
105+ title : article . title ,
106+ desc : article . description ,
107+ url : article . url ,
108+ tags : article . tags . map ( tag => tag . name ) ,
109+ author : oxfordComma ( article . authors . map ( author => author . Name ) ) ,
110+ } ) )
111+ : null ;
112+
113+ const talks =
114+ issue . talks !== null
115+ ? issue . talks . map ( talk => ( {
116+ title : talk . title ,
117+ talkURL : talk . url ,
118+ desc : talk . description ,
119+ tags : talk . tags . map ( tag => tag . name ) ,
120+ } ) )
121+ : null ;
122+
123+ const tools =
124+ issue . tools !== null
125+ ? issue . tools . map ( tool => ( {
126+ title : tool . name ,
127+ url : tool . url ,
128+ logo : getAssetURL ( issue . id , tool . logo ) ,
129+ desc : tool . description ,
130+ tags : tool . tags . map ( tag => tag . name ) ,
131+ author : oxfordComma ( tool . authors . map ( author => author . Name ) ) ,
132+ } ) )
133+ : null ;
134+
135+ const devOfTheWeek =
136+ issue . devOfTheWeek !== null
137+ ? {
138+ name : issue . devOfTheWeek . name ,
139+ profileImg : getAssetURL ( issue . id , issue . devOfTheWeek . profileImg ) ,
140+ bio : issue . devOfTheWeek . bio ,
141+ profileLink : {
142+ youtube : issue . devOfTheWeek . youtube ,
143+ github : issue . devOfTheWeek . github ,
144+ linkedin : issue . devOfTheWeek . linkedin ,
145+ website : issue . devOfTheWeek . website ,
146+ twitter : issue . devOfTheWeek . twitter ,
147+ instagram : issue . devOfTheWeek . instagram ,
148+ } ,
149+ }
150+ : null ;
151+
152+ const gif =
153+ issue . gif !== null
154+ ? {
155+ gifURL : getAssetURL ( issue . id , issue . gif . gifURL ) ,
156+ caption : issue . gif . caption ,
157+ }
158+ : null ;
159+
160+ const quiz =
161+ issue . quiz !== null
162+ ? {
163+ question : issue . quiz . question ,
164+ answerId : issue . quiz . answerId ,
165+ options : issue . quiz . Option . map ( option => ( {
166+ description : option . description ,
167+ id : option . option_id ,
168+ text : option . text ,
169+ } ) ) ,
170+ snippet : issue . quiz . CodeSnippet ,
171+ }
172+ : null ;
173+
174+ const issueData = {
175+ meta,
176+ tipOfTheWeek,
177+ articles,
178+ talks,
179+ tools,
180+ devOfTheWeek,
181+ gif,
182+ quiz,
183+ } ;
184+
185+ return issueData ;
147186}
148187
149188export function getAllIssuesMeta ( issues : IssueAPIResponse [ ] ) {
0 commit comments