Skip to content

Commit 5ed9369

Browse files
authored
Fix article API: render glossary terms for glossary page (#59647)
1 parent 4032316 commit 5ed9369

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/article-api/middleware/article-body.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Context } from '@/types'
44
import { ExtendedRequestWithPageInfo } from '@/article-api/types'
55
import contextualize from '@/frame/middleware/context/context'
66
import features from '@/versions/middleware/features'
7+
import glossaries from '@/frame/middleware/context/glossaries'
78
import { transformerRegistry } from '@/article-api/transformers'
89
import { allVersions } from '@/versions/lib/all-versions'
910
import type { Page } from '@/types'
@@ -32,6 +33,9 @@ async function createContextualizedRenderingRequest(pathname: string, page: Page
3233
// Load feature flags into context (needed for {% ifversion %} tags)
3334
features(renderingReq as ExtendedRequestWithPageInfo, {} as Response, () => {})
3435

36+
// Run page-specific contextualizers (e.g., glossaries middleware)
37+
await glossaries(renderingReq as ExtendedRequestWithPageInfo, {} as Response, () => {})
38+
3539
return renderingReq
3640
}
3741

src/article-api/tests/article-body.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ describe('article body api', () => {
7070

7171
// Removed: non-article pages test - landing pages are now supported via transformers
7272

73+
test('glossary page renders glossary terms', async () => {
74+
const res = await get(makeURL('/en/get-started/learning-about-github/github-glossary'))
75+
expect(res.statusCode).toBe(200)
76+
// Glossary terms come from the glossaries middleware context,
77+
// not from the markdown body itself.
78+
expect(res.body).toContain('## foo')
79+
expect(res.body).toContain('## check')
80+
expect(res.body).toContain('Foo is an intentionally meaningless placeholder')
81+
})
82+
7383
test('invalid Referer header does not crash', async () => {
7484
const res = await get(makeURL('/en/get-started/start-your-journey/hello-world'), {
7585
headers: {

0 commit comments

Comments
 (0)