(propName, context, opts = { unwrap: false })
| 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 |
no test coverage detected