Skip to content

Commit

Permalink
REST new user guidance (github#29642)
Browse files Browse the repository at this point in the history
  • Loading branch information
skedwards88 authored Aug 23, 2022
1 parent 0906274 commit d2a2113
Show file tree
Hide file tree
Showing 9 changed files with 1,029 additions and 366 deletions.
9 changes: 7 additions & 2 deletions components/sidebar/RestCollapsibleSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export const RestCollapsibleSection = (props: SectionProps) => {
router.query.productId === 'rest' ||
// These pages need the Article Page mini tocs instead of the Rest Pages
router.asPath.includes('/rest/guides') ||
router.asPath.includes('/rest/overview')
router.asPath.includes('/rest/overview') ||
router.asPath.includes('/rest/quickstart')
? []
: useAutomatedPageContext().miniTocItems

Expand All @@ -66,7 +67,11 @@ export const RestCollapsibleSection = (props: SectionProps) => {
}, [])

useEffect(() => {
if (!router.asPath.includes('guides') && !router.asPath.includes('overview')) {
if (
!router.asPath.includes('guides') &&
!router.asPath.includes('overview') &&
!router.asPath.includes('quickstart')
) {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
Expand Down
34 changes: 26 additions & 8 deletions components/sidebar/SidebarProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ export const SidebarProduct = () => {

const restSection = () => {
const conceptualPages = currentProductTree.childPages.filter(
(page) => page.href.includes('guides') || page.href.includes('overview')
(page) =>
page.href.includes('guides') ||
page.href.includes('overview') ||
page.href.includes('quickstart')
)
const restPages = currentProductTree.childPages.filter(
(page) => !page.href.includes('guides') && !page.href.includes('overview')
(page) =>
!page.href.includes('guides') &&
!page.href.includes('overview') &&
!page.href.includes('quickstart')
)
return (
<>
Expand All @@ -95,19 +101,31 @@ export const SidebarProduct = () => {
const isActive =
routePath.includes(childPage.href + '/') || routePath === childPage.href
const defaultOpen = hasExactCategory ? isActive : false

return (
<li
key={childPage.href + i}
data-is-active-category={isActive}
data-is-current-page={isActive && isStandaloneCategory}
className={cx('py-1', isActive && 'color-bg-inset')}
>
<ProductCollapsibleSection
defaultOpen={defaultOpen}
routePath={routePath}
title={childTitle}
page={childPage}
/>
{childPage.href.includes('quickstart') ? (
<Link
href={childPage.href}
className={cx(
'd-block pl-4 pr-5 py-1 color-fg-default text-bold no-underline width-full'
)}
>
{childTitle}
</Link>
) : (
<ProductCollapsibleSection
defaultOpen={defaultOpen}
routePath={routePath}
title={childTitle}
page={childPage}
/>
)}
</li>
)
})}
Expand Down
982 changes: 628 additions & 354 deletions content/rest/guides/getting-started-with-the-rest-api.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion content/rest/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ title: GitHub REST API
shortTitle: REST API
intro: 'To create integrations, retrieve data, and automate your workflows, build with the {% data variables.product.prodname_dotcom %} REST API.'
introLinks:
quickstart: /rest/guides/getting-started-with-the-rest-api
quickstart: /rest/quickstart
overview: /rest/guides/getting-started-with-the-rest-api
featuredLinks:
guides:
- /rest/guides/getting-started-with-the-rest-api
Expand Down Expand Up @@ -31,6 +32,7 @@ versions:
ghae: '*'
ghec: '*'
children:
- /quickstart
- /overview
- /guides
- /actions
Expand Down
351 changes: 351 additions & 0 deletions content/rest/quickstart.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pages/[versionId]/rest/quickstart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import GlobalPage from '../[productId]/index'

export { getServerSideProps } from '../[productId]/index'

export default GlobalPage
1 change: 1 addition & 0 deletions script/rest/test-open-api-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function throughDirectory(directory) {
!directory.includes('rest/guides') &&
!directory.includes('rest/overview') &&
!file.includes('index.md') &&
!file.includes('quickstart.md') &&
!file.includes('README.md')
) {
return contentFiles.push(absolute)
Expand Down
1 change: 1 addition & 0 deletions tests/rendering/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ describe('sidebar', () => {
!directory.includes('rest/guides') &&
!directory.includes('rest/overview') &&
!absolute.includes('rest/index.md') &&
!absolute.includes('rest/quickstart.md') &&
!file.includes('README.md')
) {
return contentFiles.push(absolute)
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/openapi-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ describe('markdown for each rest version', () => {
test('markdown file exists for every operationId prefix in all versions of the OpenAPI schema', async () => {
// list of REST markdown files that do not correspond to REST API resources
// TODO could we get this list dynamically, say via page frontmatter?
const excludeFromResourceNameCheck = ['README.md', 'index.md', 'guides', 'overview']
const excludeFromResourceNameCheck = [
'README.md',
'index.md',
'guides',
'overview',
'quickstart.md',
]

// Unique set of all categories across all versions of the OpenAPI schema
const allCategories = new Set()
Expand Down

0 comments on commit d2a2113

Please sign in to comment.