File tree Expand file tree Collapse file tree 7 files changed +62
-26
lines changed Expand file tree Collapse file tree 7 files changed +62
-26
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,10 @@ export default {
1212 title : 'Description Block' ,
1313 name : 'description_block' ,
1414 type : 'array' ,
15- of : [
16- {
17- type : 'block' ,
18- of : [
19- {
20- type : 'code_highlight'
21- } ,
22- ]
23- }
24- ] ,
15+ of : [ {
16+ type : 'block' ,
17+ of : [ { type : 'code_highlight' } ]
18+ } ] ,
2519 rows : 7
2620 } ,
2721 {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React from 'react'
22import Highlight , { defaultProps } from 'prism-react-renderer'
33import styled from 'styled-components'
44import duotoneLight from 'prism-react-renderer/themes/oceanicNext'
5+ import formatDescription from '../../utils/formatDescription'
56
67const Pre = styled . pre `
78 font-family: 'Inconsolata', monospace;
@@ -25,7 +26,7 @@ const LineNo = styled.span`
2526`
2627
2728export default function DescriptiveItem ( { section } ) {
28- // console.log('DescriptiveItem props: ', section)
29+ console . log ( 'DescriptiveItem props: ' , section )
2930 return (
3031 < div >
3132 { section . subsections . map ( secData => {
@@ -37,9 +38,9 @@ export default function DescriptiveItem({ section }) {
3738 >
3839 < h4 > { secData . name } </ h4 >
3940
40- { secData . description && (
41- < p > { secData . description } </ p >
42- ) }
41+ { /* { secData.description && ( */ }
42+ < p > { formatDescription ( secData ) } </ p >
43+ { /* )} */ }
4344
4445 { secData . code && (
4546 < Highlight
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import styled from 'styled-components'
3+
4+ const InlineHighlight = styled . code `
5+ padding: 2px;
6+ background-color: rgb(230, 255, 255);
7+ border-radius: 3px;
8+ `
9+
10+ export default function HighlightInlineCode ( props ) {
11+ return (
12+ < InlineHighlight >
13+ { props . code }
14+ </ InlineHighlight >
15+ )
16+ }
Original file line number Diff line number Diff line change @@ -37,8 +37,6 @@ export default function ShortcutTable(props) {
3737 }
3838 }
3939
40- // function clearSort() { setSortedRows(null) }
41-
4240 return (
4341 < div className = "table_container" >
4442 < table >
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ import DescriptiveItem from './DescriptiveItem'
88// `
99
1010export default function TopicSection ( props ) {
11- console . log ( 'TS props: ' , props ) ;
11+ // console.log('TS props: ', props);
12+
1213 return (
1314 < section
1415 id = { props . section . anchor_id }
@@ -23,7 +24,7 @@ export default function TopicSection(props) {
2324 >
2425 { props . section . name }
2526 </ h3 >
26-
27+
2728 { props . section . description && (
2829 < p className = "section_description" >
2930 { props . section . description }
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ const NavMenuBtn = styled.button`
3535`
3636
3737export default function Index ( { data } ) {
38+ // console.log('data: ', data)
3839 // these "nav" references are for the secondary nav that appears once you've scrolled past table of contents
3940 const [ navIsActive , setNavIsActive ] = useState ( false )
4041 const [ navMenuIsActive , setNavMenuIsActive ] = useState ( false )
@@ -170,6 +171,13 @@ export const query = graphql`
170171 url
171172 }
172173 _rawDescriptionBlock(resolveReferences: {maxDepth: 10})
174+ code {
175+ highlightedLines
176+ language
177+ code
178+ _type
179+ _key
180+ }
173181 }
174182 ... on SanityShortcutSubsection {
175183 id
@@ -185,13 +193,5 @@ export const query = graphql`
185193 }
186194 }
187195 }
188- # allSanityGeneralSubsection {
189- # edges {
190- # node {
191- # id
192- # _rawDescriptionBlock
193- # }
194- # }
195- # }
196196 }
197197`
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import HighlightInlineCode from '../src/components/HighlightInlineCode'
3+
4+ export default function formatDescription ( content ) {
5+ // console.log('content: ', content)
6+ const descriptionBlock = [ ]
7+ if ( content . _rawDescriptionBlock ) {
8+ content . _rawDescriptionBlock [ 0 ] . children . forEach ( inlineBlock => {
9+ // console.log('inlineBlock: ', inlineBlock)
10+ if ( inlineBlock . _type === 'code_highlight' ) {
11+ descriptionBlock . push (
12+ < HighlightInlineCode
13+ code = { inlineBlock . inline_code_highlight }
14+ key = { inlineBlock . _key }
15+ />
16+ )
17+ } else {
18+ descriptionBlock . push ( inlineBlock . text )
19+ }
20+ } )
21+ // console.log('descriptionBlock: ', descriptionBlock)
22+ return descriptionBlock
23+ } else {
24+ return content . description
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments