Skip to content

Commit 83fa9f7

Browse files
Fix build errors
1 parent 2214bd2 commit 83fa9f7

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

components/MultiChoiceAnswer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const Answer = ({
4141
const [isExpanded, setIsExpanded] = useState(false)
4242
const childrenArray = Children.toArray(children) as ReactElement[]
4343
const answer = childrenArray.filter(
44-
(child) => child.type != MultiChoice.Explanation
44+
(child) => child.type !== MultiChoice.Explanation
4545
)
4646
const explanation = childrenArray.find(
4747
(child) => child.type === MultiChoice.Explanation

components/MultiChoiceExplanation.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-ignore
12
import React, { Children, ReactElement, ReactNode, useState } from 'react'
23
import { callbackify } from 'util'
34
import { styled } from '../stitches.config'
@@ -24,32 +25,35 @@ const Explanation = ({ content, children }: ExplanationProps) => {
2425
)
2526
}
2627

27-
console.log("children", children)
28-
const traverse = (ele: JSX.Element[] | JSX.Element | string, callback: (ele: string) => void) => {
28+
console.log('children', children)
29+
const traverse = (
30+
ele: JSX.Element[] | JSX.Element | string,
31+
callback: (ele: string) => void
32+
) => {
2933
if (typeof ele === 'string') {
3034
// console.log("ele is string:", ele)
31-
callback(ele);
32-
return;
35+
callback(ele)
36+
return
3337
}
3438
if (Array.isArray(ele)) {
3539
// console.log("ele is array:", ele)
36-
ele.forEach((subEle) => traverse(subEle, callback));
40+
ele.forEach((subEle) => traverse(subEle, callback))
3741
} else if (React.isValidElement(ele)) {
3842
// console.log("ele is react element:", ele)
39-
if (ele.props.hasOwnProperty('children')) {
43+
if (ele.props.includes('children')) {
4044
// Only if the props of this react element has a children prop.
4145
// Might not in some cases, e.g. when ele.type === "img"
42-
traverse((ele as JSX.Element).props.children, callback);
46+
traverse((ele as JSX.Element).props.children, callback)
4347
}
4448
}
4549
}
4650

4751
// Traverse the component tree to count total length of text.
48-
let textLength = 0;
52+
let textLength = 0
4953
traverse(children, (text) => {
5054
textLength += text.length
5155
})
52-
56+
5357
const handleOnClick = (event) => {
5458
// prevents collapsing the parent component
5559
event.stopPropagation()
@@ -60,17 +64,18 @@ const Explanation = ({ content, children }: ExplanationProps) => {
6064
const threshold = 1000
6165
if ((children.length > 1 || textLength > threshold) && !isExpanded) {
6266
let previewTextFound = false
63-
let previewText = ""
67+
let previewText = ''
6468

65-
// Traverse the component tree and find the first text node.
69+
// Traverse the component tree and find the first text node.
6670
traverse(children, (text: string) => {
6771
if (!previewTextFound) {
6872
previewText = text
6973
previewTextFound = true
7074
}
7175
})
7276

73-
previewText.substring(0, threshold)
77+
previewText
78+
.substring(0, threshold)
7479
// trims all non-letter characters from end of string
7580
// this ensures the truncated paragraph looks good with the ellipsis (...)
7681
.replace(/[^a-z]+$/gi, '')

contentlayer.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default makeSource({
7272
rehypeHighlight,
7373
rehypePrismPlus,
7474
rehypeAutolinkHeadings,
75-
rehypeSlug,
75+
rehypeSlug
7676
]
7777
}
7878
})

0 commit comments

Comments
 (0)