1
0
mirror of synced 2025-12-23 11:54:18 -05:00

add remove-fpt helper function

This commit is contained in:
Sarah Schneider
2021-01-14 13:34:32 -05:00
parent 927ead1d5f
commit b511758057
12 changed files with 42 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
const path = require('path')
const findPage = require('./find-page')
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
const removeFPTFromPath = require('./remove-fpt-from-path')
// rawLinks is an array of paths: [ '/foo' ]
// we need to convert it to an array of localized objects: [ { href: '/en/foo', title: 'Foo', intro: 'Description here' } ]
@@ -12,7 +13,7 @@ module.exports = async (rawLinks, context, additionalProperties = []) => {
for (const link of rawLinks) {
const linkPath = link.href || link
const version = context.currentVersion === 'homepage' ? nonEnterpriseDefaultVersion : context.currentVersion
const href = path.join('/', context.currentLanguage, version, linkPath)
const href = removeFPTFromPath(path.join('/', context.currentLanguage, version, linkPath))
const linkedPage = findPage(href, context.pages, context.redirects)
if (!linkedPage) continue