@x-wave/blog 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -1
- package/index.js +504 -478
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -390,7 +390,7 @@ interface BlogConfig {
|
|
|
390
390
|
supportedLanguages: readonly string[] // e.g. ['en', 'es', 'zh']
|
|
391
391
|
navigationData: NavigationEntry[] // Menu structure
|
|
392
392
|
basePath?: string // Base path for all routes (default: '')
|
|
393
|
-
header?: {
|
|
393
|
+
header?: { // Optional: omit to hide built-in header
|
|
394
394
|
navLinks?: HeaderLink[] // Top-level nav links
|
|
395
395
|
dropdownItems?: HeaderDropdownItem[] // Support dropdown menu
|
|
396
396
|
}
|
|
@@ -399,6 +399,68 @@ interface BlogConfig {
|
|
|
399
399
|
|
|
400
400
|
**Key properties:**
|
|
401
401
|
|
|
402
|
+
- **`header`**: Optional. If omitted entirely, the built-in header component will not be rendered. Use this when you want to implement a custom header.
|
|
403
|
+
|
|
404
|
+
### Custom headers
|
|
405
|
+
|
|
406
|
+
If you need a custom header instead of the built-in one, simply omit the `header` config and use the provided hooks:
|
|
407
|
+
|
|
408
|
+
```tsx
|
|
409
|
+
import { useTheme, useSearchModal } from '@x-wave/blog'
|
|
410
|
+
import { Moon, Sun, MagnifyingGlass } from '@phosphor-icons/react'
|
|
411
|
+
|
|
412
|
+
function CustomHeader() {
|
|
413
|
+
const { theme, setTheme } = useTheme()
|
|
414
|
+
const { openSearchModal } = useSearchModal()
|
|
415
|
+
|
|
416
|
+
return (
|
|
417
|
+
<header>
|
|
418
|
+
<h1>My Custom Header</h1>
|
|
419
|
+
|
|
420
|
+
{/* Theme toggle button */}
|
|
421
|
+
<button onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
|
|
422
|
+
{theme === 'dark' ? <Sun /> : <Moon />}
|
|
423
|
+
</button>
|
|
424
|
+
|
|
425
|
+
{/* Search button */}
|
|
426
|
+
<button onClick={openSearchModal}>
|
|
427
|
+
<MagnifyingGlass />
|
|
428
|
+
</button>
|
|
429
|
+
</header>
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function App() {
|
|
434
|
+
return (
|
|
435
|
+
<BlogProvider
|
|
436
|
+
config={{
|
|
437
|
+
title: 'My Docs',
|
|
438
|
+
supportedLanguages: ['en'],
|
|
439
|
+
navigationData: NAVIGATION_DATA,
|
|
440
|
+
// No header config = no built-in header
|
|
441
|
+
}}
|
|
442
|
+
blog={blog}
|
|
443
|
+
>
|
|
444
|
+
<CustomHeader />
|
|
445
|
+
<Router>
|
|
446
|
+
<Routes>
|
|
447
|
+
<Route path="/:language/*" element={<DocumentationRoutes />} />
|
|
448
|
+
</Routes>
|
|
449
|
+
</Router>
|
|
450
|
+
</BlogProvider>
|
|
451
|
+
)
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
**Available hooks:**
|
|
456
|
+
|
|
457
|
+
- **`useTheme()`**: Returns `{ theme, setTheme, effectiveTheme }` for managing light/dark/system theme
|
|
458
|
+
- **`useSearchModal()`**: Returns `{ openSearchModal, closeSearchModal }` for controlling the search modal
|
|
459
|
+
|
|
460
|
+
These are the exact functions used by the built-in header, so you get the same functionality with full customization.
|
|
461
|
+
|
|
462
|
+
**Key properties (continued):**
|
|
463
|
+
|
|
402
464
|
| Property | Type | Required | Description |
|
|
403
465
|
|---|---|---|---|
|
|
404
466
|
| `title` | `string` | Yes | Site title displayed in header and sidebar |
|