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.
Merge pull request github#5662 from github/repo-sync
repo sync
- Loading branch information
Showing
25 changed files
with
584 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"FEATURE_TEST_TRUE": true, | ||
"FEATURE_TEST_FALSE": false | ||
"FEATURE_TEST_FALSE": false, | ||
"FEATURE_NEW_SITETREE": false | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{% for categoryPage in currentProductTree.childPages %} | ||
{% if categoryPage.href == currentPath %}{% assign currentCategory = categoryPage %}{% endif %} | ||
{% endfor %} | ||
|
||
{% if currentCategory.page.shortTitle and currentCategory.page.shortTitle != '' %}{% assign currentCategoryTitle = currentCategory.page.shortTitle %}{% else %}{% assign currentCategoryTitle = currentCategory.page.title %}{% endif %} | ||
|
||
{% assign maxArticles = 10 %} | ||
|
||
<div class="py-6 all-articles-list"> | ||
<h2 class="font-mktg mb-4">{{ currentCategoryTitle }} docs</h2> | ||
|
||
<div class="d-flex gutter flex-wrap"> | ||
{% for childPage in currentCategory.childPages %} | ||
{% unless childPage.page.hidden %} | ||
<div class="col-12 col-lg-4 mb-6 height-full"> | ||
<h4 class="mb-3"><a href="{{ childPage.href }}">{{ childPage.page.title }}</a></h4> | ||
<ul class="list-style-none"> | ||
{% for grandchildPage in childPage.childPages %} | ||
<li class="mb-3 {% if forloop.index > maxArticles %}d-none{% endif %}"> | ||
<a href="{{ grandchildPage.href }}"> | ||
{{ grandchildPage.page.title }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
{% assign numArticles = childPage.childPages | obj_size %} | ||
{% if numArticles > maxArticles %} | ||
<button class="js-all-articles-show-more btn-link Link--secondary">Show {{ numArticles | minus: maxArticles }} more {% octicon "chevron-up" class="v-align-text-bottom" %}</button> | ||
{% endif %} | ||
</ul> | ||
</div> | ||
{% endunless %} | ||
{% endfor %} | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% if tocItems %} | ||
|
||
{% for tocItem in tocItems %} | ||
|
||
{% assign title = tocItem.title %} | ||
{% assign fullPath = tocItem.fullPath %} | ||
{% assign intro = tocItem.intro %} | ||
{% include liquid-tags/link-with-intro %} | ||
|
||
{% endfor %} | ||
|
||
{% endif %} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% if tocItems %} | ||
<ul> | ||
{% for tocItem in tocItems %} | ||
|
||
{% assign title = tocItem.title %} | ||
{% assign fullPath = tocItem.fullPath %} | ||
{% assign intro = tocItem.intro %} | ||
|
||
<li>{% include liquid-tags/link %} | ||
{% if tocItem.childTocItems %} | ||
{% unless page.relativePath == "github/index.md" %} | ||
<ul> | ||
{% for childItem in tocItem.childTocItems %} | ||
{% assign title = childItem.title %} | ||
{% assign fullPath = childItem.fullPath %} | ||
<li>{% include liquid-tags/link %}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endunless %} | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% assign maxArticles = 10 %} | ||
|
||
{% if currentProductTree.page.shortTitle and currentProductTree.page.shortTitle != '' %}{% assign productTitle = currentProductTree.page.shortTitle %}{% else %}{% assign productTitle = currentProductTree.page.title %}{% endif %} | ||
|
||
<div class="py-6 all-articles-list"> | ||
<h2 class="font-mktg mb-4">All {{ productTitle }} docs</h2> | ||
|
||
<div class="d-flex gutter flex-wrap"> | ||
{% for childPage in currentProductTree.childPages %} | ||
{% if childPage.page.documentType == "article" %}{% assign standaloneCategory = true %}{% else %}{% assign standaloneCategory = false %}{% endif %} | ||
{% unless standaloneCategory %} | ||
<div class="col-12 col-lg-4 mb-6 height-full"> | ||
<h4 class="mb-3"><a href="{{ childPage.href }}">{{ childPage.page.title }}</a></h4> | ||
|
||
{% if childPage.childPages and childPage.childPages[0].page.documentType == "mapTopic" %} | ||
<ul class="list-style-none"> | ||
{% for grandchildPage in childPage.childPages %} | ||
{% unless grandchildPage.page.hidden %} | ||
{% assign numArticles = childPage.childPages | obj_size %} | ||
<li class="mb-3 {% if forloop.index > maxArticles %}d-none{% endif %}"> | ||
<a href="{{ grandchildPage.href }}"> | ||
{{ grandchildPage.page.title }} | ||
</a> | ||
</li> | ||
{% if numArticles > maxArticles %} | ||
<button class="js-all-articles-show-more btn-link Link--secondary">Show {{ numArticles | minus: maxArticles }} more {% octicon "chevron-up" class="v-align-text-bottom" %}</button> | ||
{% endif %} | ||
{% endunless %} | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
<ul class="list-style-none"> | ||
{% assign numArticles = childPage.childPages | obj_size %} | ||
{% for grandchildPage in childPage.childPages %} | ||
<li class="mb-3 {% if forloop.index > maxArticles %}d-none{% endif %}"><a href="{{ grandchildPage.href }}">{{ grandchildPage.page.title }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% if numArticles > maxArticles %} | ||
<button class="js-all-articles-show-more btn-link Link--secondary">Show {{ numArticles | minus: maxArticles }} more {% octicon "chevron-up" class="v-align-text-bottom" %}</button> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
{% endunless %} | ||
{% endfor %} | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!-- | ||
Styling note: | ||
Categories, Maptopics, and Articles list items get a class of `active` when they correspond to content | ||
hierarchy of the current page. If an item's URL is also the same as the current URL, the item | ||
also gets an `is-current-page` class. | ||
--> | ||
|
||
{% include all-products-link %} | ||
|
||
{% unless currentProductTree.page.hidden %} | ||
|
||
{% if currentProductTree.renderedShortTitle %}{% assign productTitle = currentProductTree.renderedShortTitle %}{% else %}{% assign productTitle = currentProductTree.renderedFullTitle %}{% endif %} | ||
|
||
<li title="" class="sidebar-product mb-2"> | ||
<a href="{{currentProductTree.href}}" class="pl-4 pr-5 pb-1 f4">{{ productTitle }}</a> | ||
</li> | ||
<li> | ||
<ul class="sidebar-categories list-style-none"> | ||
{% for childPage in currentProductTree.childPages %} | ||
{% if childPage.page.documentType == "article" %}{% assign standaloneCategory = true %}{% else %}{% assign standaloneCategory = false %}{% endif %} | ||
<li class="sidebar-category py-1 {% if currentPath contains childPage.href %}active {% if currentPath == childPage.href %}is-current-page {% endif %}{% endif %}{% if standaloneCategory %}standalone-category{% endif %}"> | ||
{% if childPage.renderedShortTitle %}{% assign childTitle = childPage.renderedShortTitle %}{% else %}{% assign childTitle = childPage.renderedFullTitle %}{% endif %} | ||
{% if standaloneCategory %} | ||
<a href="{{childPage.href}}" class="pl-4 pr-2 py-2 f6 text-uppercase d-block flex-auto mr-3">{{ childTitle }}</a> | ||
{% else %} | ||
<details class="dropdown-withArrow details details-reset" {% if currentPath contains childPage.href or forloop.index < 4 %}open{% endif %}> | ||
<summary> | ||
<div class="d-flex flex-justify-between"> | ||
<a href="{{childPage.href}}" class="pl-4 pr-2 py-2 f6 text-uppercase d-block flex-auto mr-3">{{ childTitle }}</a> | ||
{% if forloop.index < 4 %} | ||
<svg xmlns="http://www.w3.org/2000/svg" class="octicon flex-shrink-0 arrow mr-3" style="margin-top:7px" viewBox="0 0 16 16" width="16" height="16"> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></svg> | ||
{% endif %} | ||
</div> | ||
</summary> | ||
{% endif %} | ||
<!-- some categories have maptopics with child articles --> | ||
{% if currentPath contains childPage.href or forloop.index < 4 %} | ||
{% if childPage.childPages[0].page.documentType == "mapTopic" %} | ||
<ul class="sidebar-topics list-style-none position-relative"> | ||
{% for grandchildPage in childPage.childPages %} | ||
{% if grandchildPage.renderedShortTitle %}{% assign grandchildTitle = grandchildPage.renderedShortTitle %}{% else %}{% assign grandchildTitle = grandchildPage.renderedFullTitle %}{% endif %} | ||
<li class="sidebar-maptopic {% if currentPath contains grandchildPage.href %}active {% if currentPath == grandchildPage.href %}is-current-page{% endif %}{% endif %}"> | ||
<a href="{{grandchildPage.href}}" class="pl-4 pr-5 py-2">{{ grandchildTitle }} </a> | ||
<ul class="sidebar-articles my-2"> | ||
{% for greatgrandchildPage in grandchildPage.childPages %} | ||
{% if greatgrandchildPage.renderedShortTitle %}{% assign greatgrandchildTitle = greatgrandchildPage.renderedShortTitle %}{% else %}{% assign greatgrandchildTitle = greatgrandchildPage.renderedFullTitle %}{% endif %} | ||
<li class="sidebar-article {% if currentPath contains greatgrandchildPage.href %}active {% if currentPath == greatgrandchildPage.href %}is-current-page{% endif %}{% endif %}"> | ||
<a href="{{greatgrandchildPage.href}}" class="pl-6 pr-5 py-1{% if forloop.last %} pb-2{% endif %}">{{ greatgrandchildTitle }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
<!-- some categories have no maptopics, only articles --> | ||
{% elsif childPage.childPages[0].page.documentType == "article" %} | ||
<ul class="sidebar-articles list-style-none"> | ||
{% for grandchildPage in childPage.childPages %} | ||
{% if grandchildPage.renderedShortTitle %}{% assign grandchildTitle = grandchildPage.renderedShortTitle %}{% else %}{% assign grandchildTitle = grandchildPage.renderedFullTitle %}{% endif %} | ||
<li class="sidebar-article {% if currentPath contains grandchildPage.href %}active {% if currentPath == grandchildPage.href %}is-current-page{% endif %}{% endif %}"> | ||
<a href="{{grandchildPage.href}}" class="pl-4 pr-5 py-1{% if forloop.last %} pb-2{% endif %}">{{ grandchildTitle }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
{% endif %} | ||
</details> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
|
||
{% endunless %} |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const path = require('path') | ||
const renderOpts = { textOnly: true, encodeEntities: true } | ||
|
||
// This middleware exposes a list of all categories and child articles at /categories.json. | ||
// GitHub Support uses this for internal ZenDesk search functionality. | ||
module.exports = async function categoriesForSupport (req, res, next) { | ||
const englishSiteTree = req.context.siteTree.en | ||
|
||
const allCategories = [] | ||
|
||
await Promise.all(Object.keys(englishSiteTree).map(async (version) => { | ||
await Promise.all(englishSiteTree[version].childPages.map(async (productPage) => { | ||
if (productPage.page.relativePath.startsWith('early-access')) return | ||
if (!productPage.childPages) return | ||
|
||
await Promise.all(productPage.childPages.map(async (categoryPage) => { | ||
// We can't get the rendered titles from middleware/render-tree-titles | ||
// here because that middleware only runs on the current version, and this | ||
// middleware processes all versions. | ||
const name = categoryPage.page.title.includes('{') | ||
? await categoryPage.page.renderProp('title', req.context, renderOpts) | ||
: categoryPage.page.title | ||
|
||
allCategories.push({ | ||
name, | ||
published_articles: await findArticlesPerCategory(categoryPage, [], req.context) | ||
}) | ||
})) | ||
})) | ||
})) | ||
|
||
return res.json(allCategories) | ||
} | ||
|
||
async function findArticlesPerCategory (currentPage, articlesArray, context) { | ||
if (currentPage.page.documentType === 'article') { | ||
const title = currentPage.page.title.includes('{') | ||
? await currentPage.page.renderProp('title', context, renderOpts) | ||
: currentPage.page.title | ||
|
||
articlesArray.push({ | ||
title, | ||
slug: path.basename(currentPage.href) | ||
}) | ||
} | ||
|
||
if (!currentPage.childPages) return articlesArray | ||
|
||
// Run recursively to find any articles deeper in the tree. | ||
await Promise.all(currentPage.childPages.map(async (childPage) => { | ||
await findArticlesPerCategory(childPage, articlesArray, context) | ||
})) | ||
|
||
return articlesArray | ||
} |
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.