@@ -100,7 +100,13 @@ const H3 = styled.h3`
100100 font-family: 'Fjalla One', sans-serif;
101101 font-family: 'Cuprum', sans-serif;
102102`
103-
103+ const ListItem = styled . li `
104+ /* &:before {
105+ content: ''
106+ } */
107+ list-style-type: square;
108+ color: ${ ( { theme } ) => theme . text } ;
109+ `
104110function Post ( props ) {
105111 const [ articleBtmPos , setArticleBtmPos ] = useState ( 0 )
106112 // console.log('Post props: ', props)
@@ -117,16 +123,36 @@ function Post(props) {
117123 } )
118124 }
119125
126+ function formatListItem ( listItemParts ) {
127+ // console.log('formatListItem ', listItemParts)
128+ const listItem = [ ]
129+ for ( let i = 0 ; i < listItemParts . length ; i ++ ) {
130+ if ( listItemParts [ i ] . _type === 'inline_code' ) {
131+ listItem . push (
132+ < InlineCodeMain key = { listItemParts . _key } >
133+ { listItemParts [ i ] . str_content_inline }
134+ </ InlineCodeMain >
135+ )
136+ }
137+ else {
138+ listItem . push ( listItemParts [ i ] . text )
139+ }
140+
141+ }
142+ // console.log('listItem: ', listItem)
143+ return listItem
144+ }
145+
120146 const postContent = [ ]
121147 // TODO: change these to use functional loops?
122148 // TODO: move some of these functions to a separate file so this file is cleaner
123149 function paragraphBlock ( section ) {
124- // console.log('paragraphBlock: ', section)
150+ // console.log('paragraphBlock section : ', section)
125151 const blockContent = [ ]
126152 for ( let i = 0 ; i < section . children . length ; i ++ ) {
127153 // TODO: find a better way to check type of section
128154 if ( ! section . children [ i ] . marks ) {
129- // console.log('paragraphBlock inline code' )
155+ // console.log('section.children[i]: ', section.children[i] )
130156 blockContent . push (
131157 < InlineCodeMain key = { section . children [ i ] . _key } >
132158 { section . children [ i ] . str_content_inline }
@@ -245,37 +271,50 @@ function Post(props) {
245271 )
246272 }
247273
274+ let list = [ ]
248275 props . body && props . body . forEach ( section => {
249- switch ( section . _type ) {
250- case 'block' :
251- postContent . push (
252- paragraphBlock ( section )
253- )
254- break
255- case 'code' :
276+ if ( section . listItem ) {
277+ list . push (
278+ < ListItem > { formatListItem ( section . children ) } </ ListItem >
279+ )
280+ } else {
281+ if ( list . length > 0 ) {
256282 postContent . push (
257- prismafyCodeBlock ( section . code , section . _key )
283+ < ul > { list } </ ul >
258284 )
259- break
260- case 'post_aside' :
261- postContent . push (
262- asideStringNewlines (
263- section . str_content_newline , section . _key
285+ list = [ ]
286+ }
287+ switch ( section . _type ) {
288+ case 'block' :
289+ postContent . push (
290+ paragraphBlock ( section )
264291 )
265- )
266- break
267- case 'post_aside_with_code' :
268- // console.log('section.body: ', section.body)
269- postContent . push (
270- asideWithCode (
271- section . body , section . _key
292+ break
293+ case 'code' :
294+ postContent . push (
295+ prismafyCodeBlock ( section . code , section . _key )
272296 )
273- )
274- break
275- // default:
276- // console.log('default case')
297+ break
298+ case 'post_aside' :
299+ postContent . push (
300+ asideStringNewlines (
301+ section . str_content_newline , section . _key
302+ )
303+ )
304+ break
305+ case 'post_aside_with_code' :
306+ // console.log('section.body: ', section.body)
307+ postContent . push (
308+ asideWithCode (
309+ section . body , section . _key
310+ )
311+ )
312+ break
313+ // default:
314+ // console.log('default case')
315+ }
316+ // console.log('postContent: ', postContent)
277317 }
278- // console.log('postContent: ', postContent)
279318 } )
280319
281320
0 commit comments