MCPcopy Index your code
hub / github.com/tyroprogrammer/learn-react-app / stitchMarkdownSource

Method stitchMarkdownSource

src/setup/Markdown.jsx:31–74  ·  view source on GitHub ↗
({ tutorialMetadata })

Source from the content-addressed store, hash-verified

29 }
30
31 stitchMarkdownSource({ tutorialMetadata }) {
32 FileReader.readFile(`${tutorialMetadata.markdownLocation}`)
33 .then(markdownText => {
34 let stichedSource = [];
35 const hasExercise = markdownText.includes(EXERCISE_SPLITTER);
36 if (hasExercise) {
37 stichedSource = [];
38 const splitSource = markdownText.split(EXERCISE_SPLITTER);
39 splitSource.forEach((s, index) => {
40 stichedSource.push(
41 <ReactMarkdown
42 key={index}
43 source={s}
44 renderers={{
45 code: codeRenderer,
46 link: linkRenderer
47 }}
48 />
49 );
50 if (index < splitSource.length - 1) {
51 stichedSource.push(
52 <Exercise
53 key={`exercise-${index}`}
54 exercise={tutorialMetadata.exercises[index]}
55 />
56 );
57 }
58 });
59 } else {
60 stichedSource = [
61 <ReactMarkdown
62 key="mkdown"
63 source={markdownText}
64 renderers={{
65 code: codeRenderer,
66 link: linkRenderer
67 }}
68 />]
69 }
70 this.setState({
71 markdownSource: stichedSource
72 });
73 })
74 }
75
76 render() {
77 return (

Callers 2

componentDidMountMethod · 0.95
componentDidUpdateMethod · 0.95

Calls 1

readFileMethod · 0.80

Tested by

no test coverage detected