@x-wave/blog 1.0.16 → 1.0.18

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 CHANGED
@@ -280,10 +280,12 @@ import {
280
280
  DocumentationRoutes,
281
281
  DocumentationLayout,
282
282
  ContentPage,
283
+ HomePage,
283
284
  Header,
284
285
  Sidebar,
285
286
  TableOfContents,
286
- AdvancedModeToggle
287
+ AdvancedModeToggle,
288
+ Metadata
287
289
  } from '@x-wave/blog'
288
290
  ```
289
291
 
@@ -293,10 +295,12 @@ import {
293
295
  | `DocumentationRoutes` | Pre-configured Routes for documentation pages (recommended) |
294
296
  | `DocumentationLayout` | Page layout: header + sidebar + content |
295
297
  | `ContentPage` | Loads and renders MDX pages |
298
+ | `HomePage` | Lists latest articles with metadata (configurable via `defaultRoute`) |
296
299
  | `Header` | Top navigation bar |
297
300
  | `Sidebar` | Left navigation panel |
298
301
  | `TableOfContents` | "On this page" anchor panel |
299
302
  | `AdvancedModeToggle` | Simple/Advanced tab switch |
303
+ | `Metadata` | Displays author and publication date with icons (used in HomePage and ContentPage) |
300
304
 
301
305
  ### Hooks
302
306
 
@@ -390,6 +394,8 @@ interface BlogConfig {
390
394
  supportedLanguages: readonly string[] // e.g. ['en', 'es', 'zh']
391
395
  navigationData: NavigationEntry[] // Menu structure
392
396
  basePath?: string // Base path for all routes (default: '')
397
+ contentMaxWidth?: string // Max width for content area (default: '80rem')
398
+ defaultRoute?: string // Default route: 'latest' (home page) or article slug (default: 'latest')
393
399
  header?: { // Optional: omit to hide built-in header
394
400
  navLinks?: HeaderLink[] // Top-level nav links
395
401
  dropdownItems?: HeaderDropdownItem[] // Support dropdown menu
@@ -400,6 +406,42 @@ interface BlogConfig {
400
406
  **Key properties:**
401
407
 
402
408
  - **`header`**: Optional. If omitted entirely, the built-in header component will not be rendered. Use this when you want to implement a custom header.
409
+ - **`contentMaxWidth`**: Optional. Set a custom maximum width for the main content area. Example: `'100rem'` or `'1400px'`. Default: `'80rem'`.
410
+ - **`defaultRoute`**: Optional. Controls which page displays at the root path (`/`):
411
+ - Set to `'latest'` (default) to show the HomePage listing the latest articles
412
+ - Set to any article slug (e.g., `'welcome'`, `'getting-started'`) to redirect the root path to that article
413
+
414
+ ### Home page feature
415
+
416
+ The framework includes an optional home/latest posts page that lists articles sorted by publish date. Configure it with the `defaultRoute` option:
417
+
418
+ ```tsx
419
+ // Show home page at root path (lists latest articles)
420
+ config: {
421
+ defaultRoute: 'latest' // or omit (defaults to 'latest')
422
+ }
423
+
424
+ // Or redirect root path to a specific article
425
+ config: {
426
+ defaultRoute: 'welcome' // Root path goes to /welcome article
427
+ }
428
+ ```
429
+
430
+ The home page displays:
431
+ - **Title**: "Latest Posts" (i18n translated)
432
+ - **Header metadata**: Author and date from the most recent article
433
+ - **Article cards**: Recent articles with title, description, author, and date
434
+ - **Sorting**: Articles sorted by date (newest first), limited to 50 articles
435
+
436
+ Article metadata comes from MDX frontmatter:
437
+ ```mdx
438
+ ---
439
+ title: Getting Started
440
+ author: Jane Doe
441
+ date: 2026-02-23
442
+ description: Learn the basics in 5 minutes
443
+ ---
444
+ ```
403
445
 
404
446
  ### Custom headers
405
447
 
@@ -452,6 +494,32 @@ function App() {
452
494
  }
453
495
  ```
454
496
 
497
+ ### Reusable components
498
+
499
+ #### Metadata component
500
+
501
+ The `Metadata` component displays article metadata (author and publication date) with icons and i18n support. It's used throughout the framework (HomePage and ContentPage) but is also exported for your own use:
502
+
503
+ ```tsx
504
+ import { Metadata } from '@x-wave/blog'
505
+
506
+ function MyComponent() {
507
+ return (
508
+ <Metadata
509
+ author="Jane Doe"
510
+ date="2026-02-23"
511
+ />
512
+ )
513
+ }
514
+ ```
515
+
516
+ The component:
517
+ - Displays author with a user icon
518
+ - Displays date with a calendar icon and "Last edited" label
519
+ - Automatically formats the date using the user's locale
520
+ - Returns `null` if both author and date are missing
521
+ - Uses i18n for the "Last edited" label and date formatting
522
+
455
523
  **Available hooks:**
456
524
 
457
525
  - **`useTheme()`**: Returns `{ theme, setTheme, effectiveTheme }` for managing light/dark/system theme