CTA: register default templates on docset.yml and toc.yml - #3716
CTA: register default templates on docset.yml and toc.yml#3716bmorelli25 wants to merge 4 commits into
Conversation
Docsets can now apply a right-gutter CTA template to an entire path subtree by listing docset-relative prefixes under a template's 'paths' key, instead of adding 'cta' frontmatter to every page. Resolution order: explicit frontmatter id, then the longest matching path prefix, then the built-in trial default. An unknown frontmatter id warns and is ignored so path scopes still apply. A path claimed by two templates is a build error. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@elastic/docs-engineering I have this proposal for you. If it's too far from your vision LMK and we can close this. |
|
drive by comment, would registering the default cta in toc.yml suffice? |
Replace cta.<name>.paths in docset.yml with default_cta on docset.yml and nested toc.yml so section owners register defaults alongside their nav trees. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve docs conflict: navigation reference moved to docs/documentation/isolated/configure/index.md; port default_cta docs there and drop deleted configure/content-set/navigation.md. Co-authored-by: Cursor <cursoragent@cursor.com>
|
I've realigned this PR with your suggestion 👍 |
Mpdreamz
left a comment
There was a problem hiding this comment.
Left this open a long time sorry @bmorelli25 !
One nit.
| /// <param name="relativePath">The page's docset-root-relative source path, used for toc default lookup.</param> | ||
| /// <param name="warning">Set when <paramref name="id"/> is unknown, so the caller can report it.</param> | ||
| public Cta ResolveCta(string? id, out string? warning) | ||
| public Cta ResolveCta(string? id, string? relativePath, out string? warning) |
There was a problem hiding this comment.
This looks mostly good to me, mind writing out Cta fully e.g the return type being CallToAction in c#, using the abbreviation in config files is good though.
Cta is a pre-existing type but nice to clean up now, then all methods and variables become e.g ResolveCallToAction, the property CallToActions not Ctas.
There was a problem hiding this comment.
Done — renamed the Cta record to CallToAction, the Ctas property to CallToActions, ResolveCta to ResolveCallToAction, and ValidateCta to ValidateCallToAction across all C# source files, Razor templates, and tests. The cta abbreviation is preserved in YAML config keys (default_cta, the cta: map in docset.yml) as you suggested.
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: Mpdreamz <245275+Mpdreamz@users.noreply.github.com>
Merge conflicts are already resolved in the branch (commit |
Background
The right-gutter CTA card can now be customized per page via
ctafrontmatter (see #3602).Why is something more needed?
elastic/docs-content-internal#1475 requests adding a custom "Get started free" CTA and
onboarding_tokento all solution-specific pages undersolutions/observability/,solutions/security/, andsolutions/search. Doing this in frontmatter alone means editing ~600 files. Over time as new pages are added, folks will inevitably forget the frontmatter and we'll end up with an inconsistent mix of CTAs.The proposed solution
Register a default CTA on the navigation file that owns a section. Templates still live in
docset.yml;default_ctaondocset.ymlor a nestedtoc.ymlselects which template applies to every page listed in that file.Resolution order for a page:
ctafrontmatter id (unchanged, always wins)default_ctaregistered for the page via its navigation filetrialdefaultThis makes the docs-content side of #1475 a small change across
docset.ymlplus a few sectiontoc.ymlfiles. Pages that already carryctafrontmatter (e.g. themonitor-kubernetes/monitor-awspages from elastic/docs-content#7135) keep their more specific CTA automatically.Details: inheritance, edge cases, and one behavior change
toc.ymlpick up itsdefault_ctaautomatically.toc.ymlcan set its owndefault_cta; pages under it use that value instead of the parent navigation file's default.default_ctathat doesn't match a template indocset.yml, fails the build rather than resolving silently.ctaid warned and fell back straight to the defaulttrialcard. It still warns, but is now ignored, so a navigation default covering the page applies instead. The section CTA is more relevant than the generic card, and the warning still points at the typo.Docs for the new key are added to
docs/configure/content-set/cta.mdanddocs/configure/content-set/navigation.md.Test plan
ConfigurationFileCtaTestscovering precedence, nested toc overrides, docset-level defaults, unknown template errors, and duplicate registration errorsdefault_ctaon a sectiontoc.ymlrenders the scoped CTA on pages in that nav file and the default elsewhere