MCPcopy
hub / github.com/nilbuild/developer-roadmap / fetchTopicHtml

Method fetchTopicHtml

src/components/InteractiveRoadmap/topic.js:91–106  ·  view source on GitHub ↗
(roadmapId, topicId)

Source from the content-addressed store, hash-verified

89 }
90
91 fetchTopicHtml(roadmapId, topicId) {
92 const topicPartial = topicId.replace(/^\d+-/, '').replaceAll(/:/g, '/');
93 const fullUrl = `/${roadmapId}/${topicPartial}/`;
94
95 return fetch(fullUrl)
96 .then((res) => {
97 return res.text();
98 })
99 .then((topicHtml) => {
100 // It's full HTML with page body, head etc.
101 // We only need the inner HTML of the #main-content
102 const node = new DOMParser().parseFromString(topicHtml, 'text/html');
103
104 return node.getElementById('main-content');
105 });
106 }
107
108 handleTopicClick(e) {
109 const { roadmapId, topicId } = e.detail;

Callers 1

handleTopicClickMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected