MCPcopy
hub / github.com/code-hike/codehike / CodeWithNotes

Function CodeWithNotes

apps/web/components/code/code-with-notes.tsx:18–48  ·  view source on GitHub ↗
(props: unknown)

Source from the content-addressed store, hash-verified

16})
17
18export async function CodeWithNotes(props: unknown) {
19 const { code, notes = [] } = parseProps(props, ContentSchema)
20 const highlighted = await highlight(code, theme)
21
22 // find matches between annotations and notes
23 // and add the note as data to the annotation
24 highlighted.annotations = await Promise.all(
25 highlighted.annotations.map(async (a) => {
26 const note = notes.find((n) => a.query && n.title === a.query)
27 if (!note) return a
28
29 let children = note.children
30 if (note.code) {
31 const highlighted = await highlight(note.code, theme)
32 children = (
33 <HighCode highlighted={highlighted} className="border-none my-0" />
34 )
35 }
36
37 return {
38 ...a,
39 data: {
40 ...a.data,
41 children,
42 },
43 }
44 }),
45 )
46
47 return <HighCode highlighted={highlighted} />
48}

Callers

nothing calls this directly

Calls 2

parsePropsFunction · 0.90
highlightFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…