MCPcopy
hub / github.com/github/docs / renderProp

Method renderProp

lib/page.js:269–288  ·  view source on GitHub ↗
(propName, context, opts = { unwrap: false })

Source from the content-addressed store, hash-verified

267 // Allow other modules (like custom liquid tags) to make one-off requests
268 // for a page's rendered properties like `title` and `intro`
269 async renderProp(propName, context, opts = { unwrap: false }) {
270 let prop
271 if (propName === 'title') {
272 prop = 'rawTitle'
273 } else if (propName === 'shortTitle') {
274 prop = this.rawShortTitle ? 'rawShortTitle' : 'rawTitle'
275 } else if (propName === 'intro') {
276 prop = 'rawIntro'
277 } else {
278 prop = propName
279 }
280
281 const html = await renderContentWithFallback(this, prop, context, opts)
282
283 if (!opts.unwrap) return html
284
285 // The unwrap option removes surrounding tags from a string, preserving any inner HTML
286 const $ = cheerio.load(html, { xmlMode: true })
287 return $.root().contents().html()
288 }
289
290 // infer current page's corresponding homepage
291 // /en/articles/foo -> /en

Callers 7

renderTitleMethod · 0.95
categoriesForSupportFunction · 0.80
findArticlesPerCategoryFunction · 0.80
getTocItemsFunction · 0.80
processLinkFunction · 0.80
getNewTitleFunction · 0.80

Calls 1

Tested by

no test coverage detected