@@ -2,6 +2,7 @@ const path = require('path')
22const findPage = require ( './find-page' )
33const nonEnterpriseDefaultVersion = require ( './non-enterprise-default-version' )
44const removeFPTFromPath = require ( './remove-fpt-from-path' )
5+ const renderContent = require ( './render-content' )
56
67// rawLinks is an array of paths: [ '/foo' ]
78// we need to convert it to an array of localized objects: [ { href: '/en/foo', title: 'Foo', intro: 'Description here' } ]
@@ -27,15 +28,17 @@ module.exports = async (rawLinks, context, option = { title: true, intro: true }
2728}
2829
2930const processLink = async ( link , context , option ) => {
30- const linkPath = link . href || link
31+ const opts = { textOnly : true , encodeEntities : true }
32+ // Parse the link in case it includes Liquid conditionals
33+ const linkPath = await renderContent ( ( link . href || link ) , context , opts )
34+ if ( ! linkPath ) return null
35+
3136 const version = context . currentVersion === 'homepage' ? nonEnterpriseDefaultVersion : context . currentVersion
3237 const href = removeFPTFromPath ( path . join ( '/' , context . currentLanguage , version , linkPath ) )
3338
3439 const linkedPage = findPage ( href , context . pages , context . redirects )
3540 if ( ! linkedPage ) return null
3641
37- const opts = { textOnly : true , encodeEntities : true }
38-
3942 const result = { href, page : linkedPage }
4043
4144 if ( option . title ) {
0 commit comments