# @codesled/content

Composable content blocks for Node.js apps — flexible, pluggable, and framework-agnostic.

This package helps developers create, manage, and render structured content (like Notion-style blocks) using a minimal API. Perfect for CMS systems, blogs, page builders, or anything that needs dynamic content.

> 🛷 Part of the CodeSled developer toolkit — reusable modules that help you build apps faster.

---

## Features

- Create rich content blocks (text, images, code, video, embeds, etc.)
- Render structured HTML from your block array
- Add metadata per block (e.g. alt text for images)
- Store anywhere — DB-agnostic (Mongo, SQL, file, etc.)
- Fully portable, reusable across apps

---

## Installation

```bash
npm install @codesled/content
```

---

## Block Types Supported

- `text` – Paragraph text
- `heading` – Section headings
- `image` – External images
- `code` – Code snippets
- `quote` – Blockquotes
- `divider` – Horizontal rule
- `video` – HTML5 videos
- `embed` – Iframes (YouTube, etc.)

---

## Usage Example

```js
const { createBlock, renderBlocks } = require("@codesled/content");

const blocks = [
  createBlock({ type: "heading", content: "Welcome to CodeSled CMS" }),
  createBlock({ type: "text", content: "Create and render content blocks easily." }),
  createBlock({
    type: "image",
    content: "https://example.com/image.png",
    meta: { alt: "An example image" },
  }),
];

console.log(renderBlocks(blocks));
```

---

## Output (HTML)

```html
<h2>Welcome to CodeSled CMS</h2>
<p>Create and render content blocks easily.</p>
<img src="https://example.com/image.png" alt="An example image" />
```

---

## API

### `createBlock({ type, content, meta? })`
Creates a content block object with timestamp and optional metadata.

### `renderBlocks(blocksArray)`
Renders an array of blocks as HTML.

### `BLOCK_TYPES`
Returns all supported block types.

### `validateBlock(block)`
Throws if a block is invalid (used internally).

---

## Use Cases

- Custom CMS systems
- Blog editors
- Docs & knowledge bases
- Static site generators
- Email builders

---

## License

MIT — Free to use, modify, and integrate in personal or commercial apps.

---

> Built by [CodeSled](https://github.com/code-sled) 🛷  
> Follow us for more modules that help you build faster.