@x-wave/blog 1.0.36 → 1.0.37

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
@@ -250,8 +250,10 @@ Regular content here.
250
250
  | Field | Type | Description |
251
251
  |---|---|---|
252
252
  | `title` | `string` | Document title (informational, not displayed by framework) |
253
+ | `description` | `string` | Optional SEO description for the article. Used in the page `<meta name="description">` tag. Falls back to site-level description if not provided. |
253
254
  | `author` | `string` | Author name. Displayed below the page title with a user icon. |
254
255
  | `date` | `string` | Publication or update date. Displayed below the page title with "Last edited" label and calendar icon (i18n supported). |
256
+ | `keywords` | `string[] \| string` | Optional array of keywords or comma-separated string for SEO. Inserted into the page `<meta name="keywords">` tag. |
255
257
  | `hasAdvanced` | `boolean` | Enables Simple/Advanced mode toggle. Requires a `-advanced.mdx` variant. |
256
258
  | `tags` | `string[]` | Array of tag strings for categorizing content. Tags are automatically indexed by the framework when you pass `mdxFiles` to BlogProvider. Tags are clickable and show search results. |
257
259
 
@@ -390,6 +392,7 @@ All CSS variables are scoped to `.xw-blog-root` for isolation and to prevent con
390
392
  ```ts
391
393
  interface BlogConfig {
392
394
  title: string // Site title
395
+ description?: string // Optional default description for SEO (used as fallback if article has no description)
393
396
  logo?: React.ComponentType<{ className?: string }> // Optional logo
394
397
  supportedLanguages: readonly string[] // e.g. ['en', 'es', 'zh']
395
398
  navigationData: NavigationEntry[] // Menu structure
@@ -406,6 +409,7 @@ interface BlogConfig {
406
409
  **Key properties:**
407
410
 
408
411
  - **`header`**: Optional. If omitted entirely, the built-in header component will not be rendered. Use this when you want to implement a custom header.
412
+ - **`description`**: Optional. Default SEO description used in the page `<meta name="description">` tag. Articles can override this with their own `description` in frontmatter.
409
413
  - **`contentMaxWidth`**: Optional. Set a custom maximum width for the main content area. Example: `'100rem'` or `'1400px'`. Default: `'80rem'`.
410
414
  - **`defaultRoute`**: Optional. Controls which page displays at the root path (`/`):
411
415
  - Set to `'latest'` (default) to show the HomePage listing the latest articles
@@ -440,9 +444,52 @@ title: Getting Started
440
444
  author: Jane Doe
441
445
  date: 2026-02-23
442
446
  description: Learn the basics in 5 minutes
447
+ keywords: [getting started, tutorial, basics]
443
448
  ---
444
449
  ```
445
450
 
451
+ ### SEO and metadata
452
+
453
+ The framework automatically handles SEO metadata using React Helmet. Page `<title>`, `<meta description>`, and `<meta keywords>` tags are set based on:
454
+
455
+ **Article pages:**
456
+ - **Title**: `"{article title} | {site title}"` (if title exists in frontmatter)
457
+ - **Description**: Uses article `description` from frontmatter, falls back to site-level `description` from config
458
+ - **Keywords**: Uses article `keywords` from frontmatter (converts array to comma-separated string)
459
+
460
+ **Home page:**
461
+ - **Title**: Site title from config
462
+ - **Description**: Uses site-level `description` from config
463
+
464
+ Example setup:
465
+
466
+ ```tsx
467
+ // app.tsx
468
+ <BlogProvider
469
+ config={{
470
+ title: 'My Documentation',
471
+ description: 'Complete guide to our platform', // Fallback description
472
+ supportedLanguages: ['en', 'es'],
473
+ navigationData: NAVIGATION_DATA,
474
+ }}
475
+ blog={blog}
476
+ >
477
+ ```
478
+
479
+ Then in your MDX frontmatter:
480
+
481
+ ```mdx
482
+ ---
483
+ title: Getting Started
484
+ author: Jane Doe
485
+ date: 2026-02-23
486
+ description: Step-by-step guide to getting started in 5 minutes // Overrides site description
487
+ keywords: [getting started, setup, tutorial, beginners]
488
+ ---
489
+ ```
490
+
491
+ This ensures proper SEO for search engines and social media sharing, with support for multi-language content.
492
+
446
493
  ### Custom headers
447
494
 
448
495
  If you need a custom header instead of the built-in one, simply omit the `header` config and use the provided hooks: