m14i-blogging 0.1.3

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 ADDED
@@ -0,0 +1,564 @@
1
+ # m14i-blogging
2
+
3
+ Drag & drop blog builder with customizable layouts and content blocks for React applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install m14i-blogging @hello-pangea/dnd react-markdown remark-gfm lucide-react
9
+ # or
10
+ pnpm add m14i-blogging @hello-pangea/dnd react-markdown remark-gfm lucide-react
11
+ # or
12
+ yarn add m14i-blogging @hello-pangea/dnd react-markdown remark-gfm lucide-react
13
+ ```
14
+
15
+ ### Prerequisites
16
+
17
+ This package requires the following in your Next.js project:
18
+
19
+ #### 1. Tailwind CSS
20
+
21
+ This package uses Tailwind CSS for styling. Make sure you have Tailwind CSS installed and configured:
22
+
23
+ ```bash
24
+ npm install -D tailwindcss postcss autoprefixer
25
+ npx tailwindcss init -p
26
+ ```
27
+
28
+ Update your `tailwind.config.js` to include the package in the content paths:
29
+
30
+ ```js
31
+ /** @type {import('tailwindcss').Config} */
32
+ module.exports = {
33
+ content: [
34
+ './pages/**/*.{js,ts,jsx,tsx,mdx}',
35
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
36
+ './app/**/*.{js,ts,jsx,tsx,mdx}',
37
+ // Add this line to scan the m14i-blogging package
38
+ './node_modules/m14i-blogging/dist/**/*.{js,mjs,cjs}',
39
+ ],
40
+ theme: {
41
+ extend: {},
42
+ },
43
+ plugins: [],
44
+ }
45
+ ```
46
+
47
+ #### 2. Import the CSS
48
+
49
+ In your root layout or main CSS file, import the package styles:
50
+
51
+ **For Next.js App Router** (`app/layout.tsx`):
52
+ ```tsx
53
+ import 'm14i-blogging/styles';
54
+ import './globals.css'; // Your global styles
55
+ ```
56
+
57
+ **For Next.js Pages Router** (`pages/_app.tsx`):
58
+ ```tsx
59
+ import 'm14i-blogging/styles';
60
+ import '../styles/globals.css';
61
+ ```
62
+
63
+ **Or import in your CSS file** (`globals.css`):
64
+ ```css
65
+ @import 'm14i-blogging/styles';
66
+ ```
67
+
68
+ #### 3. shadcn/ui Components (Required for BlogBuilder only)
69
+
70
+ If you're using the **BlogBuilder** component (the editor), you need shadcn/ui components. Install them with:
71
+
72
+ ```bash
73
+ npx shadcn@latest add label input textarea select button card
74
+ ```
75
+
76
+ **Note:** If you're only using **BlogPreview** or other display components, shadcn/ui is NOT required.
77
+
78
+ ## Quick Start
79
+
80
+ ```tsx
81
+ import { BlogBuilder } from 'm14i-blogging'
82
+ import type { LayoutSection } from 'm14i-blogging'
83
+
84
+ function MyEditor() {
85
+ const [sections, setSections] = useState<LayoutSection[]>([])
86
+
87
+ return (
88
+ <BlogBuilder
89
+ sections={sections}
90
+ onChange={setSections}
91
+ />
92
+ )
93
+ }
94
+ ```
95
+
96
+ ## Configuration
97
+
98
+ ```tsx
99
+ <BlogBuilder
100
+ sections={sections}
101
+ onChange={setSections}
102
+ config={{
103
+ // Customize available layouts
104
+ layouts: [
105
+ { type: '1-column', label: 'Une colonne', icon: LayoutGrid },
106
+ { type: '2-columns', label: 'Deux colonnes', icon: Columns }
107
+ ],
108
+
109
+ // Customize available blocks
110
+ blocks: [
111
+ { type: 'text', label: 'Texte', icon: Type },
112
+ { type: 'image', label: 'Image', icon: ImageIcon }
113
+ ],
114
+
115
+ // Theme customization
116
+ theme: {
117
+ colors: {
118
+ primary: '#B87333',
119
+ border: '#e5e7eb',
120
+ background: '#ffffff'
121
+ }
122
+ },
123
+
124
+ // Callbacks
125
+ callbacks: {
126
+ onChange: (sections) => console.log('Changed:', sections),
127
+ onSave: (sections) => console.log('Saved:', sections)
128
+ },
129
+
130
+ // UI options
131
+ ui: {
132
+ showPreviewToggle: true,
133
+ compactMode: false,
134
+ sidebarWidth: '320px'
135
+ }
136
+ }}
137
+ />
138
+ ```
139
+
140
+ ## Customization & Styling
141
+
142
+ **This package is fully style customizable!** See the [Complete Styling Guide](./STYLING.md) for:
143
+
144
+ - 📦 **CSS Variables Theme System** - Quick theming with CSS variables
145
+ - 🎨 **ClassName Props** - Complete control with custom classes
146
+ - 🎭 **Theme Presets** - Pre-configured themes (dark, ocean, sunset, forest, minimal)
147
+ - 🔧 **TypeScript Support** - Fully typed theme configuration
148
+ - 📚 **Storybook Examples** - Interactive demos and playground
149
+
150
+ ### Quick Styling Examples
151
+
152
+ **Method 1: CSS Variables (Easiest)**
153
+
154
+ ```css
155
+ :root {
156
+ --blog-primary: 220 100% 50%; /* Blue theme */
157
+ --blog-font-family: 'Inter', sans-serif;
158
+ --blog-radius-lg: 1rem;
159
+ }
160
+ ```
161
+
162
+ **Method 2: ClassName Props (Most Flexible)**
163
+
164
+ ```tsx
165
+ <BlogPreview
166
+ title="My Post"
167
+ sections={sections}
168
+ classNames={{
169
+ container: "max-w-6xl mx-auto px-8",
170
+ title: "text-6xl font-black text-purple-600"
171
+ }}
172
+ />
173
+ ```
174
+
175
+ **Method 3: Theme Presets**
176
+
177
+ ```tsx
178
+ import { applyTheme, themePresets } from 'm14i-blogging';
179
+
180
+ useEffect(() => {
181
+ applyTheme(themePresets.ocean.cssVariables!);
182
+ }, []);
183
+ ```
184
+
185
+ 👉 **[Read the Full Styling Guide](./docs/STYLING.md)** for complete documentation and examples.
186
+
187
+ ## Components
188
+
189
+ ### BlogBuilder
190
+
191
+ Main drag & drop editor component.
192
+
193
+ **Props:**
194
+ - `sections`: `LayoutSection[]` - Current blog sections
195
+ - `onChange`: `(sections: LayoutSection[]) => void` - Called when sections change
196
+ - `config?`: `BlogBuilderConfig` - Configuration object
197
+
198
+ ### BlogPreview
199
+
200
+ Read-only preview of blog post with optional reading time display.
201
+
202
+ **Props:**
203
+ - `title`: `string` - Blog post title
204
+ - `sections`: `LayoutSection[]` - Blog sections to preview
205
+ - `ImageComponent?`: Custom Image component (e.g., Next.js Image)
206
+ - `classNames?`: `BlogPreviewClassNames` - Custom styling classes
207
+ - `showReadingTime?`: `boolean` - Show reading time estimate (default: false)
208
+ - `date?`: `string | Date` - Custom date to display
209
+ - `readingTimeText?`: `string` - Custom reading time text
210
+
211
+ ### ContentBlockRenderer
212
+
213
+ Renders individual content blocks (used internally).
214
+
215
+ **Props:**
216
+ - `block`: `ContentBlock` - Content block to render
217
+ - `ImageComponent?`: Custom Image component
218
+ - `classNames?`: `ContentBlockClassNames` - Custom styling classes
219
+
220
+ ### ContentBlockInlineEditor
221
+
222
+ Inline editor for content blocks (requires shadcn/ui components).
223
+
224
+ ### BlogSEO (App Router)
225
+
226
+ SEO component for Next.js App Router that renders JSON-LD structured data.
227
+
228
+ **Props:**
229
+ - `post`: `BlogPost` - Blog post with SEO metadata
230
+ - `config`: `SEOConfig` - SEO configuration
231
+ - `options?`: Optional breadcrumbs and author settings
232
+
233
+ ### BlogHead (Pages Router)
234
+
235
+ SEO component for Next.js Pages Router that renders all meta tags and structured data.
236
+
237
+ **Props:**
238
+ - `post`: `BlogPost` - Blog post with SEO metadata
239
+ - `config`: `SEOConfig` - SEO configuration
240
+ - `options?`: Optional breadcrumbs and author settings
241
+ - `children?`: Additional meta tags to include
242
+
243
+ ## Layouts
244
+
245
+ The library supports the following layout types:
246
+
247
+ ### Column Layouts
248
+ - **1-column** - Single column layout
249
+ - **2-columns** - Two equal columns
250
+ - **3-columns** - Three equal columns
251
+ - **2-columns-wide-left** - Two columns (left wider)
252
+ - **2-columns-wide-right** - Two columns (right wider)
253
+
254
+ ### Grid Layouts
255
+ - **grid-2x2** - 2×2 grid (4 cells) - Perfect for features, services
256
+ - **grid-3x3** - 3×3 grid (9 cells) - Ideal for portfolios, teams
257
+ - **grid-2x3** - 2×3 grid (6 cells) - Great for mixed content
258
+ - **grid-4-even** - 4 equal columns - Best for stats, galleries
259
+
260
+ Grid layouts let you place **any content type** in each cell (text, images, videos, PDFs, quotes).
261
+
262
+ ## Content Blocks
263
+
264
+ The library supports the following content block types:
265
+
266
+ - **Text** - Markdown-formatted text with full formatting support
267
+ - **Image** - Display images with captions and alt text
268
+ - **Video** - Embed YouTube and Vimeo videos
269
+ - **Carousel** - Interactive image slideshow with navigation, auto-play, and multiple aspect ratios
270
+ - **Quote** - Styled blockquotes with author attribution
271
+ - **PDF** - Embed or link to PDF documents
272
+
273
+ ### PDF Content Block
274
+
275
+ Display PDF documents in your blog posts:
276
+
277
+ ```tsx
278
+ const pdfBlock: PDFBlock = {
279
+ id: "pdf-1",
280
+ type: "pdf",
281
+ url: "https://example.com/document.pdf",
282
+ title: "Annual Report 2024",
283
+ description: "Financial performance overview",
284
+ displayMode: "both", // "embed" | "download" | "both"
285
+ height: "600px" // Custom height for embed
286
+ };
287
+ ```
288
+
289
+ **Display Modes:**
290
+ - `embed` - Show PDF in iframe only
291
+ - `download` - Show download button only
292
+ - `both` - Show both iframe and download (default)
293
+
294
+ ### Carousel Content Block
295
+
296
+ Interactive image slideshow with full navigation controls:
297
+
298
+ ```tsx
299
+ const carouselBlock: CarouselBlock = {
300
+ id: "carousel-1",
301
+ type: "carousel",
302
+ slides: [
303
+ {
304
+ src: "https://example.com/slide1.jpg",
305
+ alt: "Slide 1",
306
+ title: "Title", // Optional
307
+ caption: "Description" // Optional
308
+ },
309
+ // ... more slides
310
+ ],
311
+ autoPlay: true, // Auto-play slides (default: false)
312
+ autoPlayInterval: 3000, // Interval in ms (default: 3000)
313
+ showDots: true, // Show dot indicators (default: true)
314
+ showArrows: true, // Show nav arrows (default: true)
315
+ loop: true, // Loop back to start (default: true)
316
+ aspectRatio: "16/9" // "16/9" | "4/3" | "1/1" | "21/9" (default: "16/9")
317
+ };
318
+ ```
319
+
320
+ **Features:**
321
+ - ✅ Auto-play with configurable interval
322
+ - ✅ Arrow navigation (left/right)
323
+ - ✅ Dot indicators
324
+ - ✅ Loop mode
325
+ - ✅ Multiple aspect ratios
326
+ - ✅ Title & caption overlays
327
+ - ✅ Smooth transitions
328
+ - ✅ Responsive design
329
+
330
+ ## 🚀 Automatic SEO Features
331
+
332
+ **NEW!** This package now includes comprehensive automatic SEO optimization:
333
+
334
+ - ✅ **Automatic meta tag generation** (title, description, keywords)
335
+ - ✅ **Open Graph tags** for social media sharing (Facebook, LinkedIn)
336
+ - ✅ **Twitter Card tags** for optimized Twitter sharing
337
+ - ✅ **JSON-LD structured data** (Schema.org Article/BlogPosting)
338
+ - ✅ **Reading time calculation** and display
339
+ - ✅ **Auto-generated excerpts** from content
340
+ - ✅ **SEO validation and scoring** with actionable warnings
341
+ - ✅ **Next.js App Router & Pages Router** integration
342
+ - ✅ **Smart defaults** - auto-fills missing SEO fields
343
+
344
+ ### Quick SEO Setup
345
+
346
+ **1. Configure SEO settings:**
347
+
348
+ ```tsx
349
+ import type { SEOConfig } from 'm14i-blogging';
350
+
351
+ const seoConfig: SEOConfig = {
352
+ siteUrl: 'https://yourblog.com',
353
+ siteName: 'Your Blog Name',
354
+ defaultAuthor: {
355
+ name: 'Your Name',
356
+ url: 'https://yourblog.com/author/yourname',
357
+ },
358
+ twitterSite: '@yourblog',
359
+ enableStructuredData: true,
360
+ autoGenerateDefaults: true,
361
+ };
362
+ ```
363
+
364
+ **2. Add SEO to your blog posts:**
365
+
366
+ ```tsx
367
+ // Extended BlogPost type with SEO fields
368
+ const post: BlogPost = {
369
+ title: 'Your Blog Post Title',
370
+ slug: 'your-blog-post-slug',
371
+ excerpt: 'A brief description of your post',
372
+ featuredImage: 'https://example.com/image.jpg',
373
+
374
+ // SEO fields (all optional - auto-generated if missing!)
375
+ author: {
376
+ name: 'John Doe',
377
+ social: { twitter: '@johndoe' }
378
+ },
379
+ tags: ['SEO', 'React', 'Next.js'],
380
+ category: 'Web Development',
381
+ publishedDate: '2024-01-15T10:00:00Z',
382
+
383
+ sections: [/* your content */],
384
+ };
385
+ ```
386
+
387
+ **3. Use with Next.js App Router:**
388
+
389
+ ```tsx
390
+ import { generateBlogMetadata, BlogSEO } from 'm14i-blogging';
391
+
392
+ // Generate metadata for SEO
393
+ export async function generateMetadata({ params }): Promise<Metadata> {
394
+ const post = await getPost(params.slug);
395
+ return generateBlogMetadata(post, seoConfig);
396
+ }
397
+
398
+ export default function BlogPage({ params }) {
399
+ const post = getPost(params.slug);
400
+
401
+ return (
402
+ <>
403
+ <BlogSEO post={post} config={seoConfig} />
404
+ <BlogPreview
405
+ title={post.title}
406
+ sections={post.sections}
407
+ showReadingTime={true}
408
+ />
409
+ </>
410
+ );
411
+ }
412
+ ```
413
+
414
+ **4. Or use with Next.js Pages Router:**
415
+
416
+ ```tsx
417
+ import Head from 'next/head';
418
+ import { BlogHead } from 'm14i-blogging';
419
+
420
+ export default function BlogPage({ post }) {
421
+ return (
422
+ <>
423
+ <Head>
424
+ <BlogHead post={post} config={seoConfig} />
425
+ </Head>
426
+ <BlogPreview
427
+ title={post.title}
428
+ sections={post.sections}
429
+ showReadingTime={true}
430
+ />
431
+ </>
432
+ );
433
+ }
434
+ ```
435
+
436
+ ### What Gets Generated Automatically
437
+
438
+ The package automatically generates:
439
+
440
+ 1. **Meta Tags:**
441
+ - `<title>` - Page title
442
+ - `<meta name="description">` - Auto-generated from excerpt or content
443
+ - `<meta name="keywords">` - From tags
444
+ - `<link rel="canonical">` - Canonical URL
445
+
446
+ 2. **Open Graph Tags:**
447
+ - `og:title`, `og:description`, `og:image`, `og:url`
448
+ - `article:published_time`, `article:modified_time`
449
+ - `article:author`, `article:section`, `article:tag`
450
+
451
+ 3. **Twitter Card Tags:**
452
+ - `twitter:card`, `twitter:site`, `twitter:creator`
453
+ - `twitter:title`, `twitter:description`, `twitter:image`
454
+
455
+ 4. **JSON-LD Structured Data:**
456
+ - BlogPosting schema with full metadata
457
+ - Person schema for author
458
+ - Breadcrumb schema (optional)
459
+
460
+ 5. **Content Analysis:**
461
+ - Word count
462
+ - Reading time estimation
463
+ - Auto-generated excerpt
464
+ - Heading hierarchy extraction
465
+ - SEO health score
466
+
467
+ ### SEO Utilities
468
+
469
+ ```tsx
470
+ import {
471
+ // Content analysis
472
+ analyzeContent,
473
+ calculateReadingTime,
474
+ generateExcerpt,
475
+
476
+ // SEO validation
477
+ validateSEO,
478
+ getSEOScore,
479
+
480
+ // Meta generation
481
+ generateBlogMetadata,
482
+ generateHTMLMetaTags,
483
+
484
+ // Structured data
485
+ generateArticleSchema,
486
+ generateAllStructuredData,
487
+ } from 'm14i-blogging';
488
+
489
+ // Analyze blog content
490
+ const analysis = analyzeContent(post);
491
+ // { wordCount: 1250, readingTime: 5, autoExcerpt: "...", headings: [...] }
492
+
493
+ // Get SEO score and warnings
494
+ const score = getSEOScore(post, seoConfig);
495
+ // { score: 85, grade: 'good', warnings: [...] }
496
+ ```
497
+
498
+ 👉 **[Read the Complete SEO Guide](./docs/SEO_GUIDE.md)** for detailed documentation, best practices, and advanced usage.
499
+
500
+ ## Types
501
+
502
+ ```typescript
503
+ // Core types
504
+ import type {
505
+ LayoutSection,
506
+ ContentBlock,
507
+ LayoutType,
508
+ ContentBlockType,
509
+ TextBlock,
510
+ ImageBlock,
511
+ VideoBlock,
512
+ CarouselBlock,
513
+ QuoteBlock,
514
+ PDFBlock,
515
+ BlogPost,
516
+ BlogBuilderConfig
517
+ } from 'm14i-blogging'
518
+
519
+ // Theme & styling types
520
+ import type {
521
+ CSSVariablesTheme,
522
+ BlogTheme,
523
+ BlogPreviewClassNames,
524
+ ContentBlockClassNames
525
+ } from 'm14i-blogging'
526
+
527
+ // SEO types
528
+ import type {
529
+ SEOConfig,
530
+ SEOMetadata,
531
+ OpenGraphMetadata,
532
+ TwitterCardMetadata,
533
+ AuthorInfo,
534
+ ArticleSchema,
535
+ ContentAnalysis
536
+ } from 'm14i-blogging'
537
+
538
+ // Theme presets and utilities
539
+ import { themePresets, applyTheme } from 'm14i-blogging'
540
+ ```
541
+
542
+ ## Utilities
543
+
544
+ ```typescript
545
+ import {
546
+ createEmptyColumns,
547
+ getLayoutClasses,
548
+ getLayoutLabel
549
+ } from 'm14i-blogging'
550
+ ```
551
+
552
+ ## Documentation
553
+
554
+ 📚 **Complete documentation is available in the [docs](./docs/) folder:**
555
+
556
+ - **[Next.js Integration Guide](./docs/NEXTJS_INTEGRATION.md)** - Complete setup for Next.js App Router & Pages Router
557
+ - **[Quick Start Guide](./docs/QUICKSTART.md)** - Get started in 5 minutes
558
+ - **[Styling Guide](./docs/STYLING.md)** - Complete customization reference
559
+ - **[SEO Guide](./docs/SEO_GUIDE.md)** - Comprehensive SEO documentation
560
+ - **[Gallery Layouts](./docs/GALLERY_LAYOUTS.md)** - Grid layout examples and usage
561
+
562
+ ## License
563
+
564
+ MIT