()
| 126 | |
| 127 | // Create a ContentCheck object that has all the categories/subcategories and get the title from frontmatter |
| 128 | async function createContentCheckDirectory() { |
| 129 | const renderOpts = { textOnly: true } |
| 130 | |
| 131 | for (const filename of contentFiles) { |
| 132 | const { data } = frontmatter(await fs.promises.readFile(filename, 'utf8')) |
| 133 | const applicableVersions = getApplicableVersions(data.versions, filename) |
| 134 | const splitPath = filename.split('/') |
| 135 | let category = '' |
| 136 | let subCategory = '' |
| 137 | |
| 138 | if (splitPath[splitPath.length - 2] === 'rest') { |
| 139 | category = data.title |
| 140 | } else if (splitPath[splitPath.length - 3] === 'rest') { |
| 141 | filename.includes('index.md') |
| 142 | ? (category = data.shortTitle || data.title) |
| 143 | : (subCategory = data.shortTitle || data.title) |
| 144 | } |
| 145 | for (const version of applicableVersions) { |
| 146 | req.context.currentVersion = version |
| 147 | |
| 148 | if (category !== '') |
| 149 | if (category.includes('{')) { |
| 150 | await shortVersionsMiddleware(req, null, () => {}) |
| 151 | contentCheck[version].cat.push( |
| 152 | await renderContent.liquid.parseAndRender(category, req.context, renderOpts) |
| 153 | ) |
| 154 | } else { |
| 155 | contentCheck[version].cat.push(category) |
| 156 | } |
| 157 | if (subCategory !== '') |
| 158 | if (subCategory.includes('{')) { |
| 159 | await shortVersionsMiddleware(req, null, () => {}) |
| 160 | contentCheck[version].subcat.push( |
| 161 | await renderContent.liquid.parseAndRender(subCategory, req.context, renderOpts) |
| 162 | ) |
| 163 | } else { |
| 164 | contentCheck[version].subcat.push(subCategory) |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | }) |
| 170 | test("test a page where there's known sidebar short titles that use Liquid and ampersands", async () => { |
| 171 | const url = |
no test coverage detected