Skip to content

Commit b6032f2

Browse files
committed
remove helper from this branch (to be re-added in child branch for easier reviewing)
1 parent 79a7a79 commit b6032f2

8 files changed

Lines changed: 9 additions & 30 deletions

File tree

lib/all-products.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const yaml = require('js-yaml')
77
const contentDir = path.join(process.cwd(), 'content')
88
const frontmatter = require('@github-docs/frontmatter')
99
const getApplicableVersions = require('./get-applicable-versions')
10-
const removeFPTFromPath = require('./remove-fpt-from-path')
1110

1211
// the product order is determined by data/products.yml
1312
const productsFile = path.join(process.cwd(), 'data/products.yml')
@@ -47,7 +46,7 @@ sortedProductIds.forEach(productId => {
4746
const toc = slash(path.join(dir, 'index.md'))
4847
const { data } = frontmatter(fs.readFileSync(toc, 'utf8'))
4948
const applicableVersions = getApplicableVersions(data.versions, toc)
50-
const href = removeFPTFromPath(`/${applicableVersions[0]}/${productId}`)
49+
const href = `/${applicableVersions[0]}/${productId}`
5150

5251
internalProducts[productId] = {
5352
id: productId,

lib/get-link-data.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const path = require('path')
22
const findPage = require('./find-page')
33
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
4-
const removeFPTFromPath = require('./remove-fpt-from-path')
54

65
// rawLinks is an array of paths: [ '/foo' ]
76
// we need to convert it to an array of localized objects: [ { href: '/en/foo', title: 'Foo', intro: 'Description here' } ]
@@ -13,7 +12,7 @@ module.exports = async (rawLinks, context, additionalProperties = []) => {
1312
for (const link of rawLinks) {
1413
const linkPath = link.href || link
1514
const version = context.currentVersion === 'homepage' ? nonEnterpriseDefaultVersion : context.currentVersion
16-
const href = removeFPTFromPath(path.join('/', context.currentLanguage, version, linkPath))
15+
const href = path.join('/', context.currentLanguage, version, linkPath)
1716

1817
const linkedPage = findPage(href, context.pages, context.redirects)
1918
if (!linkedPage) continue

lib/permalink.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const path = require('path')
33
const patterns = require('./patterns')
44
const getApplicableVersions = require('./get-applicable-versions')
55
const allVersions = require('./all-versions')
6-
const removeFPTFromPath = require('./remove-fpt-from-path')
76

87
class Permalink {
98
constructor (languageCode, pageVersion, relativePath, title) {
@@ -14,7 +13,8 @@ class Permalink {
1413

1514
const permalinkSuffix = this.constructor.relativePathToSuffix(relativePath)
1615

17-
this.href = removeFPTFromPath(path.join('/', languageCode, pageVersion, permalinkSuffix))
16+
this.href = path.join('/', languageCode, pageVersion, permalinkSuffix)
17+
.replace(patterns.trailingSlash, '$1')
1818

1919
this.pageVersionTitle = allVersions[pageVersion].versionTitle
2020

@@ -49,7 +49,6 @@ class Permalink {
4949
return '/' + relativePath
5050
.replace('index.md', '')
5151
.replace('.md', '')
52-
.replace(patterns.trailingSlash, '$1')
5352
}
5453
}
5554

lib/redirects/permalinks.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const path = require('path')
22
const patterns = require('../patterns')
33
const supportedVersions = new Set(Object.keys(require('../all-versions')))
44
const getOldPathsFromPermalink = require('./get-old-paths-from-permalink')
5-
const removeFPTFromPath = require('../remove-fpt-from-path')
65
const { getVersionStringFromPath } = require('../path-utils')
76
const { getNewVersionedPath } = require('../old-versions-utils')
87

@@ -38,7 +37,7 @@ module.exports = function generateRedirectsForPermalinks (permalinks, redirectFr
3837
// get the old path for the current permalink version
3938
let versionedFrontmatterOldPath = path.join('/', permalink.languageCode, getNewVersionedPath(frontmatterOldPath))
4039
const versionFromPath = getVersionStringFromPath(versionedFrontmatterOldPath)
41-
versionedFrontmatterOldPath = removeFPTFromPath(versionedFrontmatterOldPath.replace(versionFromPath, permalink.pageVersion))
40+
versionedFrontmatterOldPath = versionedFrontmatterOldPath.replace(versionFromPath, permalink.pageVersion)
4241

4342
// add it to the redirects object
4443
redirects[versionedFrontmatterOldPath] = permalink.href

lib/remove-fpt-from-path.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/rewrite-local-links.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const { getNewVersionedPath } = require('./old-versions-utils')
66
const patterns = require('./patterns')
77
const { deprecated, latest } = require('./enterprise-server-releases')
88
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
9-
const removeFPTFromPath = require('./remove-fpt-from-path')
109
const allVersions = require('./all-versions')
1110
const supportedVersions = Object.keys(allVersions)
1211
const supportedPlans = Object.values(allVersions).map(v => v.plan)
@@ -80,7 +79,7 @@ function getNewHref (link, languageCode, version) {
8079
// ------ END ONE-OFF OVERRIDES ------//
8180

8281
// update the version in the link
83-
newHref = removeFPTFromPath(newHref.replace(versionFromHref, version))
82+
newHref = newHref.replace(versionFromHref, version)
8483
}
8584

8685
newHref = newHref.replace(patterns.trailingSlash, '$1')

lib/site-tree.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const addTitlesToTree = require('./site-tree-titles')
55
const allVersions = Object.keys(require('./all-versions'))
66
const { getVersionStringFromPath } = require('./path-utils')
77
const getApplicableVersions = require('./get-applicable-versions')
8-
const removeFPTFromPath = require('./remove-fpt-from-path')
98
const findPage = require('./find-page')
109

1110
// This module builds a localized tree of every page on the site
@@ -48,7 +47,7 @@ module.exports = async function buildSiteTree (pageMap, site, redirects) {
4847

4948
// item.hrefs have a default version via lib/all-products, so update to the current version
5049
const versionFromPath = getVersionStringFromPath(item.href)
51-
const versionedProductHref = removeFPTFromPath(path.join('/', languageCode, item.href.replace(versionFromPath, version)))
50+
const versionedProductHref = path.join('/', languageCode, item.href.replace(versionFromPath, version))
5251

5352
product.categories = buildCategoriesTree(page.tocItems, versionedProductHref, pageMap, redirects, version)
5453

middleware/contextualizers/rest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
const path = require('path')
22
const rest = require('../../lib/rest')
3-
const removeFPTFromPath = require('../../lib/remove-fpt-from-path')
43

54
module.exports = async function (req, res, next) {
65
req.context.rest = rest
76

87
// link to include in `Works with GitHub Apps` notes
98
// e.g. /ja/rest/reference/apps or /en/enterprise/2.20/user/rest/reference/apps
10-
req.context.restGitHubAppsLink = removeFPTFromPath(path.join(
9+
req.context.restGitHubAppsLink = path.join(
1110
'/',
1211
req.context.currentLanguage,
1312
req.context.currentVersion,
1413
'/developers/apps'
15-
))
14+
)
1615

1716
// ignore requests to non-REST reference paths
1817
if (!req.path.includes('rest/reference')) return next()

0 commit comments

Comments
 (0)