MCPcopy
hub / github.com/github/docs / processLink

Function processLink

lib/get-link-data.js:27–55  ·  view source on GitHub ↗
(link, context, option)

Source from the content-addressed store, hash-verified

25}
26
27async function processLink(link, context, option) {
28 const opts = { textOnly: true }
29 // Parse the link in case it includes Liquid conditionals
30 const linkPath = await renderContent(link.href || link, context, opts)
31 if (!linkPath) return null
32
33 const version =
34 context.currentVersion === 'homepage' ? nonEnterpriseDefaultVersion : context.currentVersion
35 const href = removeFPTFromPath(path.join('/', context.currentLanguage, version, linkPath))
36
37 const linkedPage = findPage(href, context.pages, context.redirects)
38 if (!linkedPage) return null
39
40 const result = { href, page: linkedPage }
41
42 if (option.title) {
43 result.title = await linkedPage.renderTitle(context, opts)
44 }
45
46 if (option.fullTitle) {
47 opts.preferShort = false
48 result.fullTitle = await linkedPage.renderTitle(context, opts)
49 }
50
51 if (option.intro) {
52 result.intro = await linkedPage.renderProp('intro', context, opts)
53 }
54 return result
55}

Callers 1

get-link-data.jsFile · 0.85

Calls 5

renderContentFunction · 0.85
removeFPTFromPathFunction · 0.85
renderTitleMethod · 0.80
renderPropMethod · 0.80
findPageFunction · 0.70

Tested by

no test coverage detected