forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "sitetree optimizations""
- Loading branch information
Showing
11 changed files
with
70 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,12 @@ | ||
const findPage = require('./find-page') | ||
// get the childArticles set on map topics in lib/site-tree.js | ||
module.exports = function getMapTopicContent (parentProductId, breadcrumbs, siteTree) { | ||
const childArticles = siteTree.products[parentProductId].categories[breadcrumbs.category.href].maptopics[breadcrumbs.maptopic.href].childArticles | ||
|
||
// get the page.childArticles set on english map topics in lib/site-tree.js | ||
module.exports = function getMapTopicContent (page, pageMap, redirects) { | ||
const englishPage = page.languageCode !== 'en' | ||
? findPage(`/${page.relativePath.replace(/.md$/, '')}`, pageMap, redirects, 'en') | ||
: page | ||
|
||
if (!englishPage) { | ||
console.error(`cannot find english page: ${page.fullPath}`) | ||
return | ||
} | ||
|
||
if (!englishPage.childArticles) { | ||
console.error(`error getting child articles on map topic: ${page.fullPath}`) | ||
return | ||
if (!childArticles) { | ||
console.error(`can't find child articles from siteTree for map topic '${breadcrumbs.maptopic.href}'`) | ||
} | ||
|
||
return englishPage.childArticles | ||
return childArticles | ||
.map(article => `{% link_with_intro /${article.href} %}`) | ||
.join('\n\n') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ module.exports = async (req, res, next) => { | |
const product = req.context.siteTree[req.language][req.context.currentVersion].products[req.context.currentProduct] | ||
|
||
req.context.breadcrumbs.product = { | ||
href: path.posix.join('/', req.context.currentVersion, productPath), | ||
href: path.posix.join('/', req.context.currentLanguage, req.context.currentVersion, productPath), | ||
title: product.title | ||
} | ||
|
||
|
@@ -32,7 +32,7 @@ module.exports = async (req, res, next) => { | |
// get category path | ||
// e.g., `getting-started-with-github` in /free-pro-team@latest/github/getting-started-with-github | ||
// or /[email protected]/github/getting-started-with-github | ||
const categoryPath = path.posix.join('/', req.context.currentVersion, productPath, pathParts[1]) | ||
const categoryPath = path.posix.join('/', req.context.currentLanguage, req.context.currentVersion, productPath, pathParts[1]) | ||
|
||
const category = product.categories[categoryPath] | ||
|
||
|
@@ -49,7 +49,7 @@ module.exports = async (req, res, next) => { | |
// e.g., /github/getting-started-with-github/learning-about-github | ||
let maptopic | ||
if (req.context.page.mapTopic) { | ||
const maptopicPath = path.posix.join(categoryPath, pathParts[2]) | ||
const maptopicPath = req.path | ||
|
||
maptopic = category.maptopics[maptopicPath] | ||
|
||
|
@@ -60,9 +60,7 @@ module.exports = async (req, res, next) => { | |
title: maptopic.shortTitle || maptopic.title | ||
} | ||
} else { | ||
// get article path | ||
// e.g., /github/getting-started-with-github/githubs-products | ||
const articlePath = path.posix.join(categoryPath, pathParts[2]) | ||
const articlePath = req.path | ||
|
||
// find parent maptopic if one exists | ||
// some categories don't have maptopics, e.g. site-policy | ||
|
@@ -77,17 +75,7 @@ module.exports = async (req, res, next) => { | |
} | ||
} | ||
|
||
let articleKey = '/' + req.language + articlePath | ||
let articlePage = req.context.pages[articleKey] | ||
|
||
// fall back to English if localized article does not exist | ||
if (!articlePage && req.language !== 'en') { | ||
articleKey = '/en' + articlePath | ||
articlePage = req.context.pages[articleKey] | ||
} | ||
|
||
if (!articlePage) return next() | ||
|
||
const articlePage = req.context.page | ||
const articleTitle = await articlePage.renderProp('shortTitle', req.context, { textOnly: true, encodeEntities: true }) | ||
|
||
req.context.breadcrumbs.article = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.