Skip to content

Commit ee53f96

Browse files
committed
support conditionals in sublanding FM props
1 parent 8940baf commit ee53f96

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lib/page.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,21 @@ class Page {
202202

203203
if (this.learningTracks) {
204204
const learningTracks = []
205-
for await (const trackName of this.rawLearningTracks) {
206-
const track = context.site.data['learning-tracks'][context.currentProduct][trackName]
205+
for await (const rawTrackName of this.rawLearningTracks) {
206+
// Track names in frontmatter may include Liquid conditionals
207+
const renderedTrackName = await renderContent(rawTrackName, context, { textOnly: true, encodeEntities: true })
208+
if (!renderedTrackName) continue
209+
210+
const track = context.site.data['learning-tracks'][context.currentProduct][renderedTrackName]
207211
if (!track) continue
208212
learningTracks.push({
209-
trackName,
213+
trackName: renderedTrackName,
210214
title: await renderContent(track.title, context, { textOnly: true, encodeEntities: true }),
211215
description: await renderContent(track.description, context, { textOnly: true, encodeEntities: true }),
212216
guides: await getLinkData(track.guides, context)
213217
})
214218
}
219+
215220
this.learningTracks = learningTracks
216221
}
217222

0 commit comments

Comments
 (0)