Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/mos-diner/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ versions:
contentType: landing
layout: bespoke-landing
heroTheme: mos-diner
hideSidebar: true
children:
- /content/copilot/how-tos/copilot-on-github/copilot-for-github-tasks/use-copilot-to-create-or-update-issues
- /content/copilot/tutorials/copilot-cookbook/communicate-effectively/summarize-repository-activity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Hidden Sidebar Page
intro: 'Test page for the hideSidebar frontmatter'
versions:
fpt: '*'
ghes: '*'
ghec: '*'
hideSidebar: true
---

This page renders without the doc-tree sidebar.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sidebarLink:
href: /get-started/sidebar-test
children:
- /test-child
- /hidden-sidebar
---

This is a test page for the sidebar custom link functionality.
8 changes: 8 additions & 0 deletions src/fixtures/tests/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ describe('sidebar', () => {
expect($('[data-testid="sidebar-mobile-toggle"]').length).toBe(1)
})

test('hideSidebar frontmatter drops the sidebar and its toggles', async () => {
const $: CheerioAPI = await getDOM('/get-started/sidebar-test/hidden-sidebar')
expect($('[data-container="nav"]').length).toBe(0)
expect($('[data-testid="sidebar-collapse-toggle"]').length).toBe(0)
expect($('[data-testid="sidebar-mobile-toggle"]').length).toBe(0)
expect($('[data-testid="docs-secondary-bar"]').length).toBe(1)
})

test('REST pages get the REST sidebar', async () => {
const $: CheerioAPI = await getDOM('/rest')
expect($('[data-testid=rest-sidebar-reference]').length).toBe(1)
Expand Down
7 changes: 4 additions & 3 deletions src/frame/components/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,14 @@ type LayoutBodyProps = {
}
const LayoutBody = ({ children, hasDrawer }: LayoutBodyProps) => {
const { collapsed, mobileNavOpen } = useSidebarCollapsed()
const { currentProduct } = useMainContext()
const { currentProduct, page } = useMainContext()
const isSearchResultsPage = currentProduct?.id === 'search'
const hideSidebar = page?.hideSidebar && !isSearchResultsPage
const miniTocItems = useMiniTocItems()
const hasSubBar = miniTocItems.length > 1
return (
<div className={cx('d-lg-flex', isSearchResultsPage && styles.searchColumns)}>
{collapsed && !mobileNavOpen && !isSearchResultsPage ? null : (
{hideSidebar || (collapsed && !mobileNavOpen && !isSearchResultsPage) ? null : (
<SidebarNav mobileOpen={mobileNavOpen} />
)}
<div
Expand All @@ -293,7 +294,7 @@ const LayoutBody = ({ children, hasDrawer }: LayoutBodyProps) => {
hasSubBar &&
hasDrawer &&
(collapsed ? styles.stickyStackYieldsWhenCollapsed : styles.stickyStackYieldsAtXxl),
mobileNavOpen && styles.contentHiddenForNav,
mobileNavOpen && !hideSidebar && styles.contentHiddenForNav,
)}
>
<main id="main-content" className={styles.mainContent}>
Expand Down
2 changes: 2 additions & 0 deletions src/frame/components/context/MainContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export type MainContextT = {
introPlainText?: string
hidden: boolean
noEarlyAccessBanner: boolean
hideSidebar: boolean
applicableVersions: string[]
docsTeamMetrics: string[] | null
} | null
Expand Down Expand Up @@ -228,6 +229,7 @@ export const getMainContext = async (
applicableVersions: page.permalinks.map((obj: Permalink) => obj.pageVersion),
hidden: page.hidden || false,
noEarlyAccessBanner: page.noEarlyAccessBanner || false,
hideSidebar: page.hideSidebar || false,
docsTeamMetrics: page.docsTeamMetrics || null,
}) ||
null
Expand Down
4 changes: 2 additions & 2 deletions src/frame/components/page-header/DocsSecondaryBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import styles from './DocsSecondaryBar.module.scss'
// the unversioned route matches router.route === '/search'.
export const DocsSecondaryBar = () => {
const router = useRouter()
const { isHomepageVersion, currentProduct } = useMainContext()
const { isHomepageVersion, currentProduct, page } = useMainContext()
const { t } = useTranslation('header')
const { collapsed, toggleCollapsed, mobileNavOpen, toggleMobileNav } = useSidebarCollapsed()

Expand All @@ -40,7 +40,7 @@ export const DocsSecondaryBar = () => {
<>
<div data-container="secondary-nav" data-testid="docs-secondary-bar" className={styles.bar}>
<div className={styles.leftSegment}>
{!isEarlyAccessPage && (
{!isEarlyAccessPage && !page?.hideSidebar && (
<div className={styles.toggleCell}>
<IconButton
data-testid="sidebar-collapse-toggle"
Expand Down
4 changes: 4 additions & 0 deletions src/frame/lib/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ export const schema: Schema = {
type: 'string',
enum: ['mos-diner'],
},
// Pages with no navigable children, such as event landings, can drop the doc-tree rail.
hideSidebar: {
type: 'boolean',
},
interactive: {
type: 'boolean',
},
Expand Down
2 changes: 2 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type PageFrontmatter = {
subcategory?: boolean
hidden?: boolean
noEarlyAccessBanner?: boolean
hideSidebar?: boolean
earlyAccessToc?: string
layout?: string | boolean
redirect_from?: string[]
Expand Down Expand Up @@ -340,6 +341,7 @@ export type Page = {
children?: string[]
introPlainText?: string
noEarlyAccessBanner?: boolean
hideSidebar?: boolean
communityRedirect?: {
name: string
href: string
Expand Down
Loading