remove helper from this branch (to be re-added in child branch for easier reviewing)
This commit is contained in:
@@ -7,7 +7,6 @@ const yaml = require('js-yaml')
|
|||||||
const contentDir = path.join(process.cwd(), 'content')
|
const contentDir = path.join(process.cwd(), 'content')
|
||||||
const frontmatter = require('@github-docs/frontmatter')
|
const frontmatter = require('@github-docs/frontmatter')
|
||||||
const getApplicableVersions = require('./get-applicable-versions')
|
const getApplicableVersions = require('./get-applicable-versions')
|
||||||
const removeFPTFromPath = require('./remove-fpt-from-path')
|
|
||||||
|
|
||||||
// the product order is determined by data/products.yml
|
// the product order is determined by data/products.yml
|
||||||
const productsFile = path.join(process.cwd(), 'data/products.yml')
|
const productsFile = path.join(process.cwd(), 'data/products.yml')
|
||||||
@@ -47,7 +46,7 @@ sortedProductIds.forEach(productId => {
|
|||||||
const toc = slash(path.join(dir, 'index.md'))
|
const toc = slash(path.join(dir, 'index.md'))
|
||||||
const { data } = frontmatter(fs.readFileSync(toc, 'utf8'))
|
const { data } = frontmatter(fs.readFileSync(toc, 'utf8'))
|
||||||
const applicableVersions = getApplicableVersions(data.versions, toc)
|
const applicableVersions = getApplicableVersions(data.versions, toc)
|
||||||
const href = removeFPTFromPath(`/${applicableVersions[0]}/${productId}`)
|
const href = `/${applicableVersions[0]}/${productId}`
|
||||||
|
|
||||||
internalProducts[productId] = {
|
internalProducts[productId] = {
|
||||||
id: productId,
|
id: productId,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const findPage = require('./find-page')
|
const findPage = require('./find-page')
|
||||||
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
|
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
|
||||||
const removeFPTFromPath = require('./remove-fpt-from-path')
|
|
||||||
|
|
||||||
// rawLinks is an array of paths: [ '/foo' ]
|
// 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' } ]
|
// 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 = []) => {
|
|||||||
for (const link of rawLinks) {
|
for (const link of rawLinks) {
|
||||||
const linkPath = link.href || link
|
const linkPath = link.href || link
|
||||||
const version = context.currentVersion === 'homepage' ? nonEnterpriseDefaultVersion : context.currentVersion
|
const version = context.currentVersion === 'homepage' ? nonEnterpriseDefaultVersion : context.currentVersion
|
||||||
const href = removeFPTFromPath(path.join('/', context.currentLanguage, version, linkPath))
|
const href = path.join('/', context.currentLanguage, version, linkPath)
|
||||||
|
|
||||||
const linkedPage = findPage(href, context.pages, context.redirects)
|
const linkedPage = findPage(href, context.pages, context.redirects)
|
||||||
if (!linkedPage) continue
|
if (!linkedPage) continue
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ const path = require('path')
|
|||||||
const patterns = require('./patterns')
|
const patterns = require('./patterns')
|
||||||
const getApplicableVersions = require('./get-applicable-versions')
|
const getApplicableVersions = require('./get-applicable-versions')
|
||||||
const allVersions = require('./all-versions')
|
const allVersions = require('./all-versions')
|
||||||
const removeFPTFromPath = require('./remove-fpt-from-path')
|
|
||||||
|
|
||||||
class Permalink {
|
class Permalink {
|
||||||
constructor (languageCode, pageVersion, relativePath, title) {
|
constructor (languageCode, pageVersion, relativePath, title) {
|
||||||
@@ -14,7 +13,8 @@ class Permalink {
|
|||||||
|
|
||||||
const permalinkSuffix = this.constructor.relativePathToSuffix(relativePath)
|
const permalinkSuffix = this.constructor.relativePathToSuffix(relativePath)
|
||||||
|
|
||||||
this.href = removeFPTFromPath(path.join('/', languageCode, pageVersion, permalinkSuffix))
|
this.href = path.join('/', languageCode, pageVersion, permalinkSuffix)
|
||||||
|
.replace(patterns.trailingSlash, '$1')
|
||||||
|
|
||||||
this.pageVersionTitle = allVersions[pageVersion].versionTitle
|
this.pageVersionTitle = allVersions[pageVersion].versionTitle
|
||||||
|
|
||||||
@@ -49,7 +49,6 @@ class Permalink {
|
|||||||
return '/' + relativePath
|
return '/' + relativePath
|
||||||
.replace('index.md', '')
|
.replace('index.md', '')
|
||||||
.replace('.md', '')
|
.replace('.md', '')
|
||||||
.replace(patterns.trailingSlash, '$1')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ const path = require('path')
|
|||||||
const patterns = require('../patterns')
|
const patterns = require('../patterns')
|
||||||
const supportedVersions = new Set(Object.keys(require('../all-versions')))
|
const supportedVersions = new Set(Object.keys(require('../all-versions')))
|
||||||
const getOldPathsFromPermalink = require('./get-old-paths-from-permalink')
|
const getOldPathsFromPermalink = require('./get-old-paths-from-permalink')
|
||||||
const removeFPTFromPath = require('../remove-fpt-from-path')
|
|
||||||
const { getVersionStringFromPath } = require('../path-utils')
|
const { getVersionStringFromPath } = require('../path-utils')
|
||||||
const { getNewVersionedPath } = require('../old-versions-utils')
|
const { getNewVersionedPath } = require('../old-versions-utils')
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ module.exports = function generateRedirectsForPermalinks (permalinks, redirectFr
|
|||||||
// get the old path for the current permalink version
|
// get the old path for the current permalink version
|
||||||
let versionedFrontmatterOldPath = path.join('/', permalink.languageCode, getNewVersionedPath(frontmatterOldPath))
|
let versionedFrontmatterOldPath = path.join('/', permalink.languageCode, getNewVersionedPath(frontmatterOldPath))
|
||||||
const versionFromPath = getVersionStringFromPath(versionedFrontmatterOldPath)
|
const versionFromPath = getVersionStringFromPath(versionedFrontmatterOldPath)
|
||||||
versionedFrontmatterOldPath = removeFPTFromPath(versionedFrontmatterOldPath.replace(versionFromPath, permalink.pageVersion))
|
versionedFrontmatterOldPath = versionedFrontmatterOldPath.replace(versionFromPath, permalink.pageVersion)
|
||||||
|
|
||||||
// add it to the redirects object
|
// add it to the redirects object
|
||||||
redirects[versionedFrontmatterOldPath] = permalink.href
|
redirects[versionedFrontmatterOldPath] = permalink.href
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
const slash = require('slash')
|
|
||||||
const patterns = require('./patterns')
|
|
||||||
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
|
|
||||||
|
|
||||||
// This is a convenience function to remove free-pro-team@latest from all
|
|
||||||
// **user-facing** aspects of the site (particularly URLs) while continuing to support
|
|
||||||
// free-pro-team@latest as a version both in the codebase and in content/data files.
|
|
||||||
module.exports = function removeFPTFromPath (path) {
|
|
||||||
path = process.env.FEATURE_REMOVE_FPT
|
|
||||||
? slash(path.replace(`/${nonEnterpriseDefaultVersion}`, ''))
|
|
||||||
: path
|
|
||||||
|
|
||||||
return path.replace(patterns.trailingSlash, '$1')
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ const { getNewVersionedPath } = require('./old-versions-utils')
|
|||||||
const patterns = require('./patterns')
|
const patterns = require('./patterns')
|
||||||
const { deprecated, latest } = require('./enterprise-server-releases')
|
const { deprecated, latest } = require('./enterprise-server-releases')
|
||||||
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
|
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
|
||||||
const removeFPTFromPath = require('./remove-fpt-from-path')
|
|
||||||
const allVersions = require('./all-versions')
|
const allVersions = require('./all-versions')
|
||||||
const supportedVersions = Object.keys(allVersions)
|
const supportedVersions = Object.keys(allVersions)
|
||||||
const supportedPlans = Object.values(allVersions).map(v => v.plan)
|
const supportedPlans = Object.values(allVersions).map(v => v.plan)
|
||||||
@@ -80,7 +79,7 @@ function getNewHref (link, languageCode, version) {
|
|||||||
// ------ END ONE-OFF OVERRIDES ------//
|
// ------ END ONE-OFF OVERRIDES ------//
|
||||||
|
|
||||||
// update the version in the link
|
// update the version in the link
|
||||||
newHref = removeFPTFromPath(newHref.replace(versionFromHref, version))
|
newHref = newHref.replace(versionFromHref, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
newHref = newHref.replace(patterns.trailingSlash, '$1')
|
newHref = newHref.replace(patterns.trailingSlash, '$1')
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const addTitlesToTree = require('./site-tree-titles')
|
|||||||
const allVersions = Object.keys(require('./all-versions'))
|
const allVersions = Object.keys(require('./all-versions'))
|
||||||
const { getVersionStringFromPath } = require('./path-utils')
|
const { getVersionStringFromPath } = require('./path-utils')
|
||||||
const getApplicableVersions = require('./get-applicable-versions')
|
const getApplicableVersions = require('./get-applicable-versions')
|
||||||
const removeFPTFromPath = require('./remove-fpt-from-path')
|
|
||||||
const findPage = require('./find-page')
|
const findPage = require('./find-page')
|
||||||
|
|
||||||
// This module builds a localized tree of every page on the site
|
// This module builds a localized tree of every page on the site
|
||||||
@@ -48,7 +47,7 @@ module.exports = async function buildSiteTree (pageMap, site, redirects) {
|
|||||||
|
|
||||||
// item.hrefs have a default version via lib/all-products, so update to the current version
|
// item.hrefs have a default version via lib/all-products, so update to the current version
|
||||||
const versionFromPath = getVersionStringFromPath(item.href)
|
const versionFromPath = getVersionStringFromPath(item.href)
|
||||||
const versionedProductHref = removeFPTFromPath(path.join('/', languageCode, item.href.replace(versionFromPath, version)))
|
const versionedProductHref = path.join('/', languageCode, item.href.replace(versionFromPath, version))
|
||||||
|
|
||||||
product.categories = buildCategoriesTree(page.tocItems, versionedProductHref, pageMap, redirects, version)
|
product.categories = buildCategoriesTree(page.tocItems, versionedProductHref, pageMap, redirects, version)
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const rest = require('../../lib/rest')
|
const rest = require('../../lib/rest')
|
||||||
const removeFPTFromPath = require('../../lib/remove-fpt-from-path')
|
|
||||||
|
|
||||||
module.exports = async function (req, res, next) {
|
module.exports = async function (req, res, next) {
|
||||||
req.context.rest = rest
|
req.context.rest = rest
|
||||||
|
|
||||||
// link to include in `Works with GitHub Apps` notes
|
// link to include in `Works with GitHub Apps` notes
|
||||||
// e.g. /ja/rest/reference/apps or /en/enterprise/2.20/user/rest/reference/apps
|
// e.g. /ja/rest/reference/apps or /en/enterprise/2.20/user/rest/reference/apps
|
||||||
req.context.restGitHubAppsLink = removeFPTFromPath(path.join(
|
req.context.restGitHubAppsLink = path.join(
|
||||||
'/',
|
'/',
|
||||||
req.context.currentLanguage,
|
req.context.currentLanguage,
|
||||||
req.context.currentVersion,
|
req.context.currentVersion,
|
||||||
'/developers/apps'
|
'/developers/apps'
|
||||||
))
|
)
|
||||||
|
|
||||||
// ignore requests to non-REST reference paths
|
// ignore requests to non-REST reference paths
|
||||||
if (!req.path.includes('rest/reference')) return next()
|
if (!req.path.includes('rest/reference')) return next()
|
||||||
|
|||||||
Reference in New Issue
Block a user