Skip to content

Commit b320016

Browse files
committed
parse some of the landing page frontmatter so we can respect conditionals
1 parent b9ede41 commit b320016

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

layouts/product-landing.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<div class="container-xl px-3 px-md-6 pt-3 pb-2">
1313
<header class="d-lg-flex gutter-lg mb-6">
14-
<div class="col-12 col-lg-6 mb-3 mb-lg-0">
14+
<div class="{% if page.product_video and page.product_video != '' %}col-12 col-lg-6 mb-3 mb-lg-0{% endif %}">
1515
<span class="text-mono text-gray">Product</span>
1616
<h1 class="mb-3 font-mktg">
1717
{{ page.shortTitle }}
@@ -22,24 +22,26 @@ <h1 class="mb-3 font-mktg">
2222
</h1>
2323
<div class="lead-mktg text-gray">{{ page.intro }}</div>
2424

25-
<a href="{{ page.introLinks.quickstart }}" class="btn-mktg btn-large f4 mt-3 mr-3">
25+
{% if page.introLinks.quickstart and page.introLinks.quickstart != '' %}
26+
<a href="{{ currentPath }}{{ page.introLinks.quickstart }}" class="btn-mktg btn-large f4 mt-3 mr-3">
2627
{% data ui.product_landing.quick_start %}
2728
</a>
29+
{% endif %}
2830

29-
{% if page.introLinks.reference %}
30-
<a href="{{ page.introLinks.reference }}" class="btn-mktg btn-outline-mktg btn-large f4 mt-3 mr-3">
31+
{% if page.introLinks.reference and page.introLinks.reference != '' %}
32+
<a href="{{ currentPath }}{{ page.introLinks.reference }}" class="btn-mktg btn-outline-mktg btn-large f4 mt-3 mr-3">
3133
{% data ui.product_landing.reference_guides %}
3234
</a>
3335
{% endif %}
3436

35-
{% if page.introLinks.overview %}
36-
<a href="{{ page.introLinks.overview }}" class="btn-mktg btn-outline-mktg btn-large f4 mt-3 mr-3">
37+
{% if page.introLinks.overview and page.introLinks.overview != '' %}
38+
<a href="{{ currentPath }}{{ page.introLinks.overview }}" class="btn-mktg btn-outline-mktg btn-large f4 mt-3 mr-3">
3739
{% data ui.product_landing.overview %}
3840
</a>
3941
{% endif %}
4042
</div>
4143

42-
{% if page.product_video %}
44+
{% if page.product_video and page.product_video != '' %}
4345
<div class="col-12 col-lg-6">
4446
<div class="position-relative" style="padding-bottom:56.25%;">
4547
{% unless process.env.AIRGAP %}

lib/frontmatter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ const schema = {
109109
},
110110
// Show in `product-landing.html`
111111
product_video: {
112-
type: 'string',
113-
format: 'url'
112+
type: 'string'
114113
},
115114
interactive: {
116115
type: 'boolean'

lib/page.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class Page {
6868
this.rawPermissions = this.permissions
6969
this.rawLearningTracks = this.learningTracks
7070
this.rawIncludeGuides = this.includeGuides
71+
this.raw_product_video = this.product_video
72+
73+
if (this.introLinks) {
74+
this.introLinks.rawQuickstart = this.introLinks.quickstart
75+
this.introLinks.rawReference = this.introLinks.reference
76+
this.introLinks.rawOverview = this.introLinks.overview
77+
}
7178

7279
// a page should only be available in versions that its parent product is available in
7380
const versionsParentProductIsNotAvailableIn = getApplicableVersions(this.versions, this.fullPath)
@@ -146,6 +153,13 @@ class Page {
146153
this.introPlainText = await renderContent(this.rawIntro, context, { textOnly: true })
147154
this.title = await renderContent(this.rawTitle, context, { textOnly: true, encodeEntities: true })
148155
this.shortTitle = await renderContent(this.shortTitle, context, { textOnly: true, encodeEntities: true })
156+
this.product_video = await renderContent(this.raw_product_video, context, { textOnly: true })
157+
158+
if (this.introLinks) {
159+
this.introLinks.quickstart = await renderContent(this.introLinks.rawQuickstart, context, { textOnly: true })
160+
this.introLinks.reference = await renderContent(this.introLinks.rawReference, context, { textOnly: true })
161+
this.introLinks.overview = await renderContent(this.introLinks.rawOverview, context, { textOnly: true })
162+
}
149163

150164
let markdown = this.mapTopic
151165
// get the map topic child articles from the siteTree

0 commit comments

Comments
 (0)