-
-
Notifications
You must be signed in to change notification settings - Fork 12
Add page layout options: "wide" and "standalone" layouts for full-width and iframe embedding with automatic detection #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
|
@copilot Looks good. I also want to have a layout called standalone or something similar. This should hide everything and just displays the content. Maybe this could be activated by using a url parameter, so that every page of the hyperbook can easily be using in an iframe. |
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Added standalone layout in commit 7f42d53. Features:
The URL parameter approach allows embedding any Hyperbook page without modifying its source. |
|
@copilot the content is cut of only a few Pixel from the heading are visible in the standalone mode. |
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Fixed in commit 0b3e5da. The issue was that the grid template still reserved space for the header even though it was hidden. Updated the standalone layout CSS to set |
|
@copilot instead of placing the docs in advanced feature create a new section for layouts. |
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Reorganized in commit 4d89fd0. Created a new "Layouts" section and moved both wide-layout-demo.md and standalone-layout-demo.md from the advanced section to the new layouts section (in both English and German). |
|
@copilot write the documentation in the normal layout. Maybe remove the section and add only one page layout.md in the advanced features, which documents all layout options. Also add links to the demos pages with hide enable in the frontmatter. So that the demos do not appear in the navigation. |
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Consolidated in commit ed1df5e. Created single |
|
@copilot would it be possible to detect if the page is inside an iframe and then to automatically set it to standalone and also to hide the toc and qrcode buttons? |
…ttons Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Implemented in commit a2c7f8b. Pages now automatically detect when they're embedded in an iframe and switch to standalone mode. The TOC toggle and QR code buttons are automatically hidden in standalone mode (whether activated by iframe detection, URL parameter, or frontmatter). This provides seamless embedding without any configuration needed. |
|
@copilot write a pnpm changeset and update the change log in website/en. The hyperbook package should also be considered for a minor version bump. |
Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
Created changeset and updated changelog in commit 78f4ab2. The changeset includes minor version bumps for hyperbook, @hyperbook/markdown, and @hyperbook/types packages. Changelog entry added for v0.61.0 with comprehensive feature descriptions including page layout options, automatic iframe detection, and smart UI hiding. |
Overview
This PR implements page layout options for Hyperbook pages, allowing pages to choose between the standard layout with a sidebar, a "wide" layout that provides full-width content with drawer-only navigation, and a "standalone" layout designed for iframe embedding with automatic detection.
Changes
Core Implementation
Type System (
packages/types/src/index.ts)Layouttype with options:"default"|"wide"|"standalone"HyperbookPageFrontmatterwith optionallayoutpropertyRendering (
packages/markdown/src/rehypeShell.ts)ctx.navigation.current?.layout)layout-wideCSS class whenlayout: wideis setlayout-standaloneCSS class whenlayout: standaloneis setStyling (
packages/markdown/assets/shell.css).main-grid.layout-wide:.main-grid.layout-standalone:JavaScript Enhancement (
packages/markdown/assets/client.js)checkStandaloneMode()function with multiple activation methods:?standalone=trueURL parameterwindow.self !== window.topDocumentation & Examples
Configuration Documentation
layouts.mdpage in Advanced Features section (English and German)Demo Pages
wide-layout-demo.mdandstandalone-layout-demo.md(English and German)hide: true) but accessible via links in documentationTesting
Added 4 new tests in
packages/markdown/tests/rehypeShell.test.ts:layout: widesetdefaultlayout: standalonesetAll 94 tests passing ✅
Release Management
Changeset (
.changeset/add-layout-options.md)hyperbook@hyperbook/markdown@hyperbook/typesChangelog (
website/en/book/changelog.md)Usage
Default Layout
Standard layout with visible sidebar (no configuration needed):
Wide Layout
Full-width content with drawer-only navigation:
Standalone Layout
Method 1: Frontmatter
Method 2: URL Parameter (works on any page without modification)
Method 3: Automatic Detection (NEW!)
Pages automatically switch to standalone mode when embedded in an iframe - no configuration needed:
When in standalone mode (via any method), TOC toggle and QR code buttons are automatically hidden for a cleaner embedded experience.
Use Cases
Wide Layout is ideal for:
Standalone Layout is ideal for:
Implementation Notes
layoutproperty continue to work with default layoutDocumentation Organization
All layout documentation is consolidated in a single
layouts.mdpage in the Advanced Features section. Demo pages are placed in the same section withhide: truein their frontmatter, making them accessible via direct links without cluttering the navigation menu.Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.