fix(docs-infra): restore the edit link on decorative header pages

The 34 pages using `<docs-decorative-header>` 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.
This commit is contained in:
Kam
2026-08-30 22:54:00 +03:00
committed by Matthew Beck
parent d9afca095b
commit acdac1cb89
2 changed files with 18 additions and 2 deletions
@@ -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
<div class="docs-header-content">
<docs-breadcrumb></docs-breadcrumb>
${getPageTitle(token.title)}
${getPageTitle(token.title, (renderer.parser.renderer as AdevDocsRenderer).context.markdownFilePath)}
<p>${token.body}</p>
</div>
@@ -97,7 +98,7 @@ function getGradientDecorativeHeader(renderer: RendererThis, token: DocsDecorati
<div class="docs-decorative-header-container">
<div class="docs-decorative-gradient-header">
<div class="docs-header-content">
${getPageTitle(token.title)}
${getPageTitle(token.title, (renderer.parser.renderer as AdevDocsRenderer).context.markdownFilePath)}
<p>${token.body}</p>
</div>
<!-- illustration -->
@@ -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(
`<docs-decorative-header title="Custom Title" gradientBackground="${gradientBackground}"></docs-decorative-header>`,
{...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',
);
});
}
});