CTA: allow scoping templates to path subtrees via paths#3716
Open
bmorelli25 wants to merge 1 commit into
Open
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>
Member
Author
|
@elastic/docs-engineering I have this proposal for you. If it's too far from your vision LMK and we can close this. |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The right-gutter CTA card can now be customized per page via
ctafrontmatter (#3602) 🎉 . This PR propsoes a new way customize the CTA card. elastic/docs-content-internal#1475 requests adding a custom "Get started free" CTA andonboarding_tokento all solution-specific pages undersolutions/observability/,solutions/security/, and thesolutions/searc. Doing this in frontmatter alone means editing ~600 files. Over time as new pages are added, it is innevitable that some or all will forget to add this frontmatter and we'll get to a place where a random selection of pages uses the custom CTA.The proposed solution
A CTA template in
docset.ymlcan now declarepaths: docset-relative path prefixes it applies to. Every page under a listed prefix gets that template, no frontmatter needed.Resolution order for a page:
ctafrontmatter id (unchanged, always wins)pathsscope covering the pagetrialdefaultThis makes the docs-content side of #1475 a small
docset.yml-only PR, and the pages that already carryctafrontmatter (e.g. themonitor-kubernetes/monitor-awspages from elastic/docs-content#7135) keep their more specific CTA automatically.Details: matching rules, edge cases, and one behavior change
solutions/observabilitycoverssolutions/observability/apps/apm.mdbut notsolutions/observability-labs/index.md. Prefixes are normalized (slashes and separators), matched case-insensitively.observabilitytosolutions/observabilityand a more specific template tosolutions/observability/get-started.ctaid warned and fell back straight to the defaulttrialcard. It still warns, but is now ignored, so a path scope 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.md.Test plan
ConfigurationFileCtaTestscovering precedence, whole-segment matching, longest-prefix-wins, normalization, and the two error cases (594/594 pass)pathsscope renders the scoped CTA on pages under the prefix and the default elsewhereMade with Cursor