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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mdx-cv/core

v0.1.0

Published

Convert MDX documents to PDF using [`@react-pdf/renderer`](https://react-pdf.org/).

Readme

@mdx-cv/core

Convert MDX documents to PDF using @react-pdf/renderer.

How it works

MDX string
  │
  ▼ compile()           @mdx-js/mdx → function-body JS (no top-level imports)
  │                     recma plugin strips whitespace-only "\n" literals
  ▼ run()               inject react runtime + useMDXComponents + baseUrl
  │                     relative imports in MDX resolve from the source file's directory
  ▼ renderToStream()    MDXProvider maps HTML elements → react-pdf components
  │
  ▼ NodeJS.ReadableStream (PDF bytes)

No temp files are written to disk. The compiled function-body is executed in-memory with run().

Installation

pnpm add @mdx-cv/core

Usage

basicRenderer

import { basicRenderer } from "@mdx-cv/core";
import { createWriteStream } from "node:fs";
import { pipeline } from "node:stream/promises";

const mdx = `
# John Doe

Software Engineer · [email protected]

## Experience

- Company A (2020–2024)
- Company B (2018–2020)
`;

const baseUrl = new URL("file:///path/to/resume.mdx");
const stream = await basicRenderer(mdx, baseUrl);

await pipeline(stream, createWriteStream("resume.pdf"));

Renderer class

import { Renderer } from "@mdx-cv/core";

const renderer = new Renderer(mdx, baseUrl, {
  pageSize: "A4",
  lang: "en",
});

const stream = await renderer.renderToPdf();

Options

| Option | Type | Default | Description | | ----------- | ------------------------------------------------------- | ------- | ----------------------------------------------------------- | | pageSize | 'A4' \| 'LETTER' \| { width: number; height: number } | 'A4' | PDF page size | | lang | string | — | BCP 47 language tag. zh* selects Noto Sans SC font family | | debugfile | boolean | false | Write compiled JSX to output.debug.jsx for inspection |

Supported MDX elements

| MDX / HTML element | Rendered as | | ------------------ | ------------------------ | | h1h6 | Headings | | p | Paragraph | | ul, ol | Unordered/ordered list | | li | List item with bullet | | blockquote | Block quote | | pre / code | Code block / inline code | | strong | Bold text | | em | Italic text | | a | Link | | img | Image | | hr | Horizontal rule |

Images

Image src values are resolved in this order:

  1. HTTP/HTTPS — passed through as-is
  2. data: URI — passed through as-is
  3. file:// URL — converted to an absolute POSIX path via fileURLToPath()
  4. Relative path — resolved against the MDX source file's directory (using the baseUrl you provide), then converted to an absolute POSIX path
![Profile photo](./photo.jpg)

The baseUrl you pass to basicRenderer / Renderer determines which directory relative paths resolve from.

Architecture

packages/core/src/
├── modules/
│   └── renderer/
│       ├── index.ts          Renderer class + basicRenderer export
│       ├── mdx-to-jsx.ts     compile() MDX → function-body JS (+ recma whitespace plugin)
│       ├── load-jsx.ts       run() function-body → React component (in-memory)
│       ├── mdx-to-pdf.tsx    renderToStream() React component → PDF stream
│       └── Wrap.tsx          Document/Page wrapper, provides MDXProvider + MdxBaseUrlContext
└── elements/
    ├── index.tsx             ElementMap: HTML tag → react-pdf component
    ├── utils.tsx             MdxBaseUrlContext, renderMixed(), markAsBlock()
    ├── heading.tsx
    ├── paragraph.tsx
    ├── list.tsx
    ├── image.tsx
    ├── link.tsx
    ├── code.tsx
    ├── blockquote.tsx
    ├── horizontal-rule.tsx
    ├── root.tsx
    ├── emphasis.tsx
    └── strong.tsx

renderMixed(children)

react-pdf requires inline content (text, links, emphasis…) inside <Text> and block content (<View>-based components) outside <Text>. renderMixed handles mixed children automatically:

  • Runs of inline nodes are collected into a single <Text>
  • Block nodes (registered with markAsBlock()) are emitted directly

This is used internally by Paragraph, ListItem, and any element that can contain both inline and block children.

Development

# Run tests
pnpm test

# Type-check
pnpm typecheck

# Build
pnpm build