MCPcopy
hub / github.com/github/docs / indexOfLearningTrackGuide

Function indexOfLearningTrackGuide

middleware/learning-track.js:102–118  ·  view source on GitHub ↗
(trackGuidePaths, guidePath, context)

Source from the content-addressed store, hash-verified

100// Find the index of a learning track guide path in an array of guide paths,
101// return -1 if not found.
102async function indexOfLearningTrackGuide(trackGuidePaths, guidePath, context) {
103 let guideIndex = -1
104
105 for (let i = 0; i < trackGuidePaths.length; i++) {
106 // Learning track URLs may have Liquid conditionals.
107 const renderedGuidePath = await renderContent(trackGuidePaths[i], context, { textOnly: true })
108
109 if (!renderedGuidePath) continue
110
111 if (renderedGuidePath === guidePath) {
112 guideIndex = i
113 break
114 }
115 }
116
117 return guideIndex
118}

Callers 1

learningTrackFunction · 0.85

Calls 1

renderContentFunction · 0.85

Tested by

no test coverage detected