Change product landing page introLinks to a general map of link titles to links (#26360)
* Add cta button to frontmatter and context * Add cta to Page * Render cta button in product landing hero * Handle external links * Add simple unit test for cta link * Address feedback Co-authored-by: Peter Bengtsson <mail@peterbe.com> * Actually push condition update * Show it's an external link * Refactor FullLink so we use Link once Co-authored-by: Peter Bengtsson <mail@peterbe.com> * Custom link can also be null * Rename 'cta' to 'custom' and make it the last introLink * Update tests with 'cta' to 'custom' change * Filter once * Revert "Filter once" This reverts commit a3f9a8a06b505d77fed47ca96a66c187c86c3c91. * Update introLinks to a map of titles and URLs * No more custom introLink in LandingHero * Simplify introLinks processing * introLinks can also be null Co-authored-by: Peter Bengtsson <mail@peterbe.com> * more concise Co-authored-by: Peter Bengtsson <mail@peterbe.com> * No longer necessary with the a plain introLinks map Co-authored-by: Peter Bengtsson <mail@peterbe.com> * '.entries()` is simpler Co-authored-by: Peter Bengtsson <mail@peterbe.com> * 'link' could be false depending on what version you're on * Update test for new introLinks Co-authored-by: Peter Bengtsson <mail@peterbe.com>
This commit is contained in:
31
lib/page.js
31
lib/page.js
@@ -90,12 +90,7 @@ class Page {
|
||||
this.rawLearningTracks = this.learningTracks
|
||||
this.rawIncludeGuides = this.includeGuides
|
||||
this.raw_product_video = this.product_video
|
||||
|
||||
if (this.introLinks) {
|
||||
this.introLinks.rawQuickstart = this.introLinks.quickstart
|
||||
this.introLinks.rawReference = this.introLinks.reference
|
||||
this.introLinks.rawOverview = this.introLinks.overview
|
||||
}
|
||||
this.rawIntroLinks = this.introLinks
|
||||
|
||||
// Is this the Homepage or a Product, Category, Topic, or Article?
|
||||
this.documentType = getDocumentType(this.relativePath)
|
||||
@@ -209,18 +204,6 @@ class Page {
|
||||
|
||||
this.product_video = await renderContent(this.raw_product_video, context, { textOnly: true })
|
||||
|
||||
if (this.introLinks) {
|
||||
this.introLinks.quickstart = await renderContent(this.introLinks.rawQuickstart, context, {
|
||||
textOnly: true,
|
||||
})
|
||||
this.introLinks.reference = await renderContent(this.introLinks.rawReference, context, {
|
||||
textOnly: true,
|
||||
})
|
||||
this.introLinks.overview = await renderContent(this.introLinks.rawOverview, context, {
|
||||
textOnly: true,
|
||||
})
|
||||
}
|
||||
|
||||
context.relativePath = this.relativePath
|
||||
const html = await renderContentCacheByContext('markdown')(this.markdown, context)
|
||||
|
||||
@@ -260,6 +243,18 @@ class Page {
|
||||
this.learningTracks = learningTracks
|
||||
}
|
||||
|
||||
// introLinks may contain Liquid and need to have versioning processed.
|
||||
if (this.rawIntroLinks) {
|
||||
const introLinks = {}
|
||||
for (const [rawKey, value] of Object.entries(this.rawIntroLinks)) {
|
||||
introLinks[rawKey] = await renderContent(value, context, {
|
||||
textOnly: true,
|
||||
})
|
||||
}
|
||||
|
||||
this.introLinks = introLinks
|
||||
}
|
||||
|
||||
if (this.rawIncludeGuides) {
|
||||
this.allTopics = []
|
||||
this.includeGuides = await getLinkData(this.rawIncludeGuides, context)
|
||||
|
||||
Reference in New Issue
Block a user