Skip to content

Commit 285a28f

Browse files
authored
Merge pull request #46518 from github/repo-sync
Repo sync
2 parents 3869fae + 58e277a commit 285a28f

9 files changed

Lines changed: 35 additions & 5 deletions

File tree

‎content/mos-diner/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ versions:
1010
contentType: landing
1111
layout: bespoke-landing
1212
heroTheme: mos-diner
13+
hideSidebar: true
1314
children:
1415
- /content/copilot/how-tos/copilot-on-github/copilot-for-github-tasks/use-copilot-to-create-or-update-issues
1516
- /content/copilot/tutorials/copilot-cookbook/communicate-effectively/summarize-repository-activity
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Hidden Sidebar Page
3+
intro: 'Test page for the hideSidebar frontmatter'
4+
versions:
5+
fpt: '*'
6+
ghes: '*'
7+
ghec: '*'
8+
hideSidebar: true
9+
---
10+
11+
This page renders without the doc-tree sidebar.

‎src/fixtures/fixtures/content/get-started/sidebar-test/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sidebarLink:
1010
href: /get-started/sidebar-test
1111
children:
1212
- /test-child
13+
- /hidden-sidebar
1314
---
1415

1516
This is a test page for the sidebar custom link functionality.

‎src/fixtures/tests/sidebar.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ describe('sidebar', () => {
1414
expect($('[data-testid="sidebar-mobile-toggle"]').length).toBe(1)
1515
})
1616

17+
test('hideSidebar frontmatter drops the sidebar and its toggles', async () => {
18+
const $: CheerioAPI = await getDOM('/get-started/sidebar-test/hidden-sidebar')
19+
expect($('[data-container="nav"]').length).toBe(0)
20+
expect($('[data-testid="sidebar-collapse-toggle"]').length).toBe(0)
21+
expect($('[data-testid="sidebar-mobile-toggle"]').length).toBe(0)
22+
expect($('[data-testid="docs-secondary-bar"]').length).toBe(1)
23+
})
24+
1725
test('REST pages get the REST sidebar', async () => {
1826
const $: CheerioAPI = await getDOM('/rest')
1927
expect($('[data-testid=rest-sidebar-reference]').length).toBe(1)

‎src/frame/components/DefaultLayout.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,14 @@ type LayoutBodyProps = {
276276
}
277277
const LayoutBody = ({ children, hasDrawer }: LayoutBodyProps) => {
278278
const { collapsed, mobileNavOpen } = useSidebarCollapsed()
279-
const { currentProduct } = useMainContext()
279+
const { currentProduct, page } = useMainContext()
280280
const isSearchResultsPage = currentProduct?.id === 'search'
281+
const hideSidebar = page?.hideSidebar && !isSearchResultsPage
281282
const miniTocItems = useMiniTocItems()
282283
const hasSubBar = miniTocItems.length > 1
283284
return (
284285
<div className={cx('d-lg-flex', isSearchResultsPage && styles.searchColumns)}>
285-
{collapsed && !mobileNavOpen && !isSearchResultsPage ? null : (
286+
{hideSidebar || (collapsed && !mobileNavOpen && !isSearchResultsPage) ? null : (
286287
<SidebarNav mobileOpen={mobileNavOpen} />
287288
)}
288289
<div
@@ -293,7 +294,7 @@ const LayoutBody = ({ children, hasDrawer }: LayoutBodyProps) => {
293294
hasSubBar &&
294295
hasDrawer &&
295296
(collapsed ? styles.stickyStackYieldsWhenCollapsed : styles.stickyStackYieldsAtXxl),
296-
mobileNavOpen && styles.contentHiddenForNav,
297+
mobileNavOpen && !hideSidebar && styles.contentHiddenForNav,
297298
)}
298299
>
299300
<main id="main-content" className={styles.mainContent}>

‎src/frame/components/context/MainContext.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export type MainContextT = {
120120
introPlainText?: string
121121
hidden: boolean
122122
noEarlyAccessBanner: boolean
123+
hideSidebar: boolean
123124
applicableVersions: string[]
124125
docsTeamMetrics: string[] | null
125126
} | null
@@ -228,6 +229,7 @@ export const getMainContext = async (
228229
applicableVersions: page.permalinks.map((obj: Permalink) => obj.pageVersion),
229230
hidden: page.hidden || false,
230231
noEarlyAccessBanner: page.noEarlyAccessBanner || false,
232+
hideSidebar: page.hideSidebar || false,
231233
docsTeamMetrics: page.docsTeamMetrics || null,
232234
}) ||
233235
null

‎src/frame/components/page-header/DocsSecondaryBar.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import styles from './DocsSecondaryBar.module.scss'
2424
// the unversioned route matches router.route === '/search'.
2525
export const DocsSecondaryBar = () => {
2626
const router = useRouter()
27-
const { isHomepageVersion, currentProduct } = useMainContext()
27+
const { isHomepageVersion, currentProduct, page } = useMainContext()
2828
const { t } = useTranslation('header')
2929
const { collapsed, toggleCollapsed, mobileNavOpen, toggleMobileNav } = useSidebarCollapsed()
3030

@@ -40,7 +40,7 @@ export const DocsSecondaryBar = () => {
4040
<>
4141
<div data-container="secondary-nav" data-testid="docs-secondary-bar" className={styles.bar}>
4242
<div className={styles.leftSegment}>
43-
{!isEarlyAccessPage && (
43+
{!isEarlyAccessPage && !page?.hideSidebar && (
4444
<div className={styles.toggleCell}>
4545
<IconButton
4646
data-testid="sidebar-collapse-toggle"

‎src/frame/lib/frontmatter.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ export const schema: Schema = {
260260
type: 'string',
261261
enum: ['mos-diner'],
262262
},
263+
// Pages with no navigable children, such as event landings, can drop the doc-tree rail.
264+
hideSidebar: {
265+
type: 'boolean',
266+
},
263267
interactive: {
264268
type: 'boolean',
265269
},

‎src/types/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export type PageFrontmatter = {
4141
subcategory?: boolean
4242
hidden?: boolean
4343
noEarlyAccessBanner?: boolean
44+
hideSidebar?: boolean
4445
earlyAccessToc?: string
4546
layout?: string | boolean
4647
redirect_from?: string[]
@@ -340,6 +341,7 @@ export type Page = {
340341
children?: string[]
341342
introPlainText?: string
342343
noEarlyAccessBanner?: boolean
344+
hideSidebar?: boolean
343345
communityRedirect?: {
344346
name: string
345347
href: string

0 commit comments

Comments
 (0)