npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

astro-marp

v0.1.1

Published

Astro integration for Marp markdown presentations with content collections support

Downloads

248

Readme

🎯 Astro-Marp Integration

A powerful Astro integration that transforms .marp Markdown slide sources into optimized presentation pages with full asset pipeline integration and server-side Mermaid diagram rendering.

Status: 100% CompleteProduction Ready

Key Features: 🎨 6 Built-in Themes | 🖼️ Auto Image Optimization | 📊 Server-Side Mermaid Diagrams | 🛣️ Dual-Mode Routing

🚀 Quick Start

Installation

# Install the integration (includes Sharp for image optimization)
npm install astro-marp

# Install Playwright for Mermaid diagram support (optional)
npm install playwright
npx playwright install chromium

Notes:

  • Sharp is bundled with the integration for automatic image optimization
  • Playwright is required only if you want to use Mermaid diagrams in your presentations

Configuration

// astro.config.mjs
import { defineConfig } from 'astro/config';
import { marp } from 'astro-marp';

export default defineConfig({
  integrations: [
    marp({
      defaultTheme: 'am_blue',           // Built-in theme (am_blue, am_brown, am_dark, am_green, am_purple, am_red)
      enableMermaid: true,               // Enable Mermaid diagram support (default: true)
      mermaidStrategy: 'inline-svg',     // Mermaid rendering strategy (default: 'inline-svg')
      debug: false,                      // Enable debug logging (default: false)
    })
  ]
});

Mermaid Diagram Support

Installation Requirements: Mermaid rendering requires Playwright to be installed:

npm install playwright
npx playwright install chromium

Configuration Options:

| Option | Type | Default | Description | |--------|------|---------|-------------| | enableMermaid | boolean | true | Enable/disable Mermaid diagram support | | mermaidStrategy | string | 'inline-svg' | Rendering strategy (see below) |

Rendering Strategies:

All Mermaid diagrams are rendered at build time (server-side). Choose the output format:

| Strategy | Output Format | Pros | Cons | |----------|--------------|------|------| | inline-svg (default) | Inline SVG | ✅ No separate files✅ Fastest page load✅ No extra requests | ⚠️ Increases HTML size | | img-svg | SVG image files | ✅ Cacheable by browser✅ Good for many diagrams✅ Smaller HTML | ⚠️ Separate file requests | | img-png | PNG image files | ✅ Maximum compatibility✅ Works everywhere | ⚠️ Larger file sizes⚠️ Not scalable | | pre-mermaid | <pre> tags | ✅ For custom rendering | ⚠️ Advanced use only |

Usage Example:

<!-- src/pages/my-presentation.marp -->
---
marp: true
theme: am_blue
title: "Architecture Overview"
---

# System Architecture

```mermaid
graph TD
  A[Client] --> B[API Gateway]
  B --> C[Service A]
  B --> D[Service B]
  C --> E[Database]
  D --> E

Sequence Flow

sequenceDiagram
  participant User
  participant App
  participant API
  User->>App: Click Button
  App->>API: POST /data
  API-->>App: 200 OK
  App-->>User: Show Success

**Supported Diagram Types**:
- Flowcharts (`graph TD`, `graph LR`)
- Sequence Diagrams (`sequenceDiagram`)
- Class Diagrams (`classDiagram`)
- State Diagrams (`stateDiagram`)
- ER Diagrams (`erDiagram`)
- Gantt Charts (`gantt`)
- Pie Charts (`pie`)
- Git Graphs (`gitGraph`)
- User Journey (`journey`)
- And more...

**Performance Considerations**:
- Build time increases with more diagrams (Playwright automation)
- `inline-svg`: Best for presentations with few diagrams
- `img-svg`/`img-png`: Better for presentations with many diagrams (browser caching)

Set up your own Astro project like the example: [astro-marp-example](https://github.com/astro-marp/astro-marp-example)

## 📝 Usage

### Option 1: Direct Page Routing (src/pages/)

Create a `.marp` file in your `src/pages/` directory:

```markdown
<!-- src/pages/my-presentation.marp -->
---
marp: true
theme: am_blue
title: "My Presentation"
headingDivider: 2
---

# Welcome

This is my presentation

## Slide 2

More content here

Access at: http://localhost:4321/my-presentation

Option 2: Content Collections (src/content/)

Create a collection and query programmatically:

<!-- src/content/presentations/demo.marp -->
---
marp: true
theme: am_blue
title: "Demo Presentation"
---

# Demo

Content here

Query in your pages:

---
// src/pages/presentations/[...slug].astro
import { getCollection } from 'astro:content';

export async function getStaticPaths() {
  const presentations = await getCollection('presentations');
  return presentations.map((presentation) => ({
    params: { slug: presentation.slug },
    props: { presentation },
  }));
}

const { presentation } = Astro.props;
const { Content } = await presentation.render();
---
<Content />

✨ Features

✅ Implemented

  • 🎨 Built-in Themes: 6 themes from Awesome-Marp are ready to use (am_blue, am_brown, am_dark, am_green, am_purple, am_red)
  • 🖼️ Image Optimization: Local images automatically optimized to WebP via Astro's pipeline with Sharp
    • Appears in Astro's "generating optimized images" console output
    • Automatic format conversion (WebP), quality optimization (80%)
    • Content-based hashing for caching
  • 📊 Mermaid Diagrams: Server-side rendering of Mermaid diagrams at build time
    • Standard ```mermaid fenced code block syntax
    • Multiple output formats (inline SVG, SVG images, PNG images)
    • No client-side JavaScript required
    • All diagram types supported (flowcharts, sequence, class, state, etc.)
    • Powered by rehype-mermaid + Playwright
  • 🛣️ Dual-Mode Routing:
    • src/pages/: Direct page routing (e.g., src/pages/demo.marp/demo)
    • src/content/: Content collections with programmatic access
    • Both modes work simultaneously
  • 📚 Content Collections: Full integration with Astro's content collections API
  • ⚡ Fast Builds: Clean build pipeline without conflicts
  • 🔧 TypeScript Support: Complete type safety and IntelliSense
  • 🎯 Error Handling: Graceful failure with helpful error messages
  • 🐛 Debug Mode: Optional debug: true config for verbose logging

📦 Requirements

  • Node.js: >=22.0.0
  • Astro: ^5.14.0
  • Sharp: ^0.33.0 (bundled automatically)
    • Included as a dependency for image optimization
    • Supports all major platforms (Linux, macOS, Windows)
  • Playwright: ^1.49.0 (required for Mermaid diagrams)
    • Install with: npm install playwright
    • Initialize with: npx playwright install chromium
    • Only needed if using Mermaid diagram support

📖 Documentation

| Document | Purpose | Status | |----------|---------|--------| | IMPLEMENTATION_SUMMARY.md | Complete architecture overview | ✅ Complete | | requirements.md | Updated requirements with status | ✅ Complete | | SPEC_PLAN_TASKS.md | Detailed specification and roadmap | ✅ Complete | | CLAUDE.md | Development guidance for AI assistants | ✅ Complete |

🏗️ Architecture

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   .marp files   │───▶│  Vite Plugin     │───▶│ Astro Components│
│                 │    │  Transformation  │    │                 │
└─────────────────┘    └──────────────────┘    └─────────────────┘
         │                       │                       │
         ▼                       ▼                       ▼
┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│ Local Images    │───▶│ Image Pipeline   │───▶│ dist/_astro/    │
│ ./images/x.svg  │    │ Optimization     │    │ x.hash.svg      │
└─────────────────┘    └──────────────────┘    └─────────────────┘

🚀 Development

Setup

git clone https://github.com/astro-marp/astro-marp
cd astro-marp
pnpm install
pnpm run build

# Test in example project
git clone https://github.com/astro-marp/astro-marp-example
cd astro-marp-example
pnpm install
pnpm run dev

Testing

# Manual testing
npm run dev        # Development server
npm run build      # Production build

# Check optimization
ls dist/_astro/    # Should contain optimized images

📊 Project Status

Implementation Progress

  • Core Integration: 90% ✅
  • Image Optimization: 100% ✅
  • Build Pipeline: 95% ✅
  • Documentation: 85% ✅

🐛 Known Issues & Troubleshooting

1. Incompatible with Tailwind CSS

  • Presentation pages generated by the Marp CLI include full HTML + CSS. When injecting the rendered result into an Astro page, omit (or override) the default layout to avoid style conflicts. Example:
---
import { CollectionEntry, getCollection } from 'astro:content';

export async function getStaticPaths() {
  const presentations = await getCollection('presentation');

  return presentations.map((presentation) => ({
    params: { slug: presentation.slug },
    props: { presentation },
  }));
}

interface Props {
  presentation: CollectionEntry<'presentation'>;
}

const { presentation } = Astro.props;
const { Content } = await presentation.render();
---
<Content />

2. Mermaid Diagrams Not Rendering

Symptom: Mermaid diagrams display as plain text instead of rendered diagrams.

Solution:

  1. Ensure Playwright is installed:

    npm install playwright
    npx playwright install chromium
  2. Check configuration - Mermaid support is enabled by default:

    // astro.config.mjs
    marp({
      enableMermaid: true,        // Should be true (default)
      mermaidStrategy: 'inline-svg'  // Valid strategy
    })
  3. Enable debug mode to see processing details:

    marp({
      debug: true  // Shows detailed processing logs
    })
  4. Verify diagram syntax - Use standard Mermaid fenced code blocks:

    ```mermaid
    graph TD
      A --> B
    ```

Common Issues:

  • Missing Playwright: Install with npm install playwright && npx playwright install chromium
  • Invalid diagram syntax: Test your diagram at mermaid.live
  • Build errors: Check build output for rehype-mermaid errors

🤝 Contributing

The project follows the astro-typst pattern and integrates deeply with Astro's lifecycle. Key areas for contribution:

  • Page Routing: Restore direct .marp file routing
  • Documentation: User guides and tutorials

📄 License

MIT License - see LICENSE file for details

🙏 Acknowledgments


Ready to create amazing presentations with Astro? 🎉

Check out the comprehensive documentation above and start building!