From acdac1cb89df320b43cd20f1163ad17480d06b2f Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Aug 2026 22:54:00 +0300 Subject: [PATCH] fix(docs-infra): restore the edit link on decorative header pages The 34 pages using `` render their title through `getPageTitle()` without passing the markdown file path, so the "Edit this page" link is silently dropped. Every other page keeps it. Compare https://v19.angular.dev/guide/components, which still has the pencil, against https://angular.dev/guide/components, which does not. `filePath` was required until #63536 made it optional, so API descriptions with no editable source could render a title without a link. That removed the compile error forcing the decorative header to supply it, and the argument was lost with nothing to catch it. Pass the path again and cover both header variants with tests, since the edit link had no coverage at all. --- .../marked/extensions/docs-decorative-header.mts | 5 +++-- .../docs-decorative-header.spec.mts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/adev/shared-docs/pipeline/shared/marked/extensions/docs-decorative-header.mts b/adev/shared-docs/pipeline/shared/marked/extensions/docs-decorative-header.mts index 486be349283..e5b5b0f69fa 100644 --- a/adev/shared-docs/pipeline/shared/marked/extensions/docs-decorative-header.mts +++ b/adev/shared-docs/pipeline/shared/marked/extensions/docs-decorative-header.mts @@ -8,6 +8,7 @@ import {TokenizerThis, Tokens, RendererThis} from 'marked'; import {loadWorkspaceRelativeFile} from '../helpers.mjs'; +import {AdevDocsRenderer} from '../renderer.mjs'; import {getPageTitle} from '../transformations/heading.mjs'; interface DocsDecorativeHeaderToken extends Tokens.Generic { @@ -75,7 +76,7 @@ function getStandardDecorativeHeader(renderer: RendererThis, token: DocsDecorati
- ${getPageTitle(token.title)} + ${getPageTitle(token.title, (renderer.parser.renderer as AdevDocsRenderer).context.markdownFilePath)}

${token.body}

@@ -97,7 +98,7 @@ function getGradientDecorativeHeader(renderer: RendererThis, token: DocsDecorati
- ${getPageTitle(token.title)} + ${getPageTitle(token.title, (renderer.parser.renderer as AdevDocsRenderer).context.markdownFilePath)}

${token.body}

diff --git a/adev/shared-docs/pipeline/shared/marked/test/docs-decorative-header/docs-decorative-header.spec.mts b/adev/shared-docs/pipeline/shared/marked/test/docs-decorative-header/docs-decorative-header.spec.mts index 236d4658b7c..f7bd5fbdf38 100644 --- a/adev/shared-docs/pipeline/shared/marked/test/docs-decorative-header/docs-decorative-header.spec.mts +++ b/adev/shared-docs/pipeline/shared/marked/test/docs-decorative-header/docs-decorative-header.spec.mts @@ -33,4 +33,19 @@ describe('markdown to html', () => { it('passes the header text to the content', () => { expect(markdownDocument.querySelector('p')?.textContent?.trim()).toBe('This is header text'); }); + + for (const gradientBackground of [false, true]) { + it(`links to the source file on GitHub (gradientBackground=${gradientBackground})`, () => { + const markdownDocument = JSDOM.fragment( + parseMarkdown( + ``, + {...rendererContext, markdownFilePath: 'adev/src/content/overview.md'}, + ), + ); + + expect(markdownDocument.querySelector('.docs-github-links')?.getAttribute('href')).toBe( + 'https://github.com/angular/angular/edit/main/adev/src/content/overview.md', + ); + }); + } });