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

@puralex/astro-markdown-for-agents

v0.3.0

Published

Markdown for Agents integration for Astro with text/markdown negotiation, static Markdown files, and llms.txt

Downloads

499

Readme

Markdown for Agents for Astro

Serve clean Markdown and generate llms.txt from Astro sites—static or SSR, including Cloudflare Free.

npm version npm downloads CI Astro 4–7 GPL-3.0

Documentation · Live converter demo · Astro integration directory

What it does

  • Returns text/markdown when a runtime request sends Accept: text/markdown.
  • Generates a parallel .md file for every page in static builds.
  • Generates llms.txt with links to machine-readable pages.
  • Detects known AI crawler User-Agents, with custom-agent support.
  • Preserves normal HTML, JSON, CSS, image, and browser responses.
  • Runs on edge runtimes with zero runtime package dependencies.

Install

pnpm add @puralex/astro-markdown-for-agents
// astro.config.mjs
import { defineConfig } from 'astro/config';
import markdownForAgents from '@puralex/astro-markdown-for-agents';

export default defineConfig({
  integrations: [markdownForAgents()],
});

Run astro build. Output includes HTML, matching Markdown files, and llms.txt.

Choose a delivery mode

| Astro deployment | Markdown delivery | Required setup | |---|---|---| | Server-rendered | Same URL via Accept: text/markdown | Astro server adapter | | Static | Direct .md URLs generated at build | None | | Static with same-URL negotiation | Generated .md files | Host/CDN rewrite |

Static hosts cannot run Astro middleware. GitHub Pages, for example, serves /index.md directly but does not inspect Accept headers.

Runtime negotiation

Use server output and any compatible Astro adapter:

import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
import markdownForAgents from '@puralex/astro-markdown-for-agents';

export default defineConfig({
  output: 'server',
  adapter: cloudflare(),
  integrations: [markdownForAgents()],
});
# Markdown
curl -i -H "Accept: text/markdown" http://localhost:4321/

# Normal HTML
curl -i http://localhost:4321/

Runtime Markdown responses include:

Content-Type: text/markdown; charset=utf-8
Vary: Accept, User-Agent

Static output

For a normal static build:

dist/
├── index.html
├── index.md
├── about/
│   ├── index.html
│   └── index.md
└── llms.txt

Agents can request /index.md, /about/index.md, or discover pages through /llms.txt.

Configuration

markdownForAgents({
  // Add custom User-Agent substrings.
  additionalAgents: ['MyInternalCrawler'],

  // Generate llms.txt during static builds. Default: true.
  generateLlmsTxt: true,

  // llms.txt metadata.
  siteTitle: 'Product Documentation',
  siteDescription: 'API, deployment, and operations guides.',
});

Supported agents

Built-in matching includes:

  • OpenAI: GPTBot, ChatGPT-User, OAI-SearchBot
  • Anthropic: anthropic-ai, Claude-Web, ClaudeBot
  • Perplexity: PerplexityBot, Perplexity-User
  • Google, Apple, Amazon, Meta, Cohere, Common Crawl, and other known crawlers

Explicit Accept: text/markdown negotiation is preferred when the client supports it. User-Agent detection handles crawlers that do not send that header.

Converter API

The zero-dependency converter is also available directly:

import { htmlToMarkdown } from '@puralex/astro-markdown-for-agents/html-to-markdown';

const markdown = htmlToMarkdown('<main><h1>Hello</h1><p>Clean output.</p></main>');

Compatibility

| Astro | Node | |---|---| | 4–5 | Node 20+ | | 6–7 | Node 22.12+ |

Package output is compiled JavaScript with TypeScript declarations. CI runs unit tests, real middleware integration tests, example builds, and package checks.

Why not Cloudflare's managed feature?

Cloudflare's Markdown for Agents provides managed runtime conversion on Pro, Business, and Enterprise plans. This integration moves conversion into Astro:

  • Server-rendered sites convert through Astro middleware.
  • Static sites generate Markdown during the Astro build.
  • Cloudflare Free users can use either mode without enabling the paid managed feature.

See the Cloudflare Free setup guide.

Development

pnpm install
pnpm check
pnpm test
pnpm --filter astro-markdown-for-agents-example build
pnpm docs:build

Current suite: 86 unit tests and 13 end-to-end middleware tests.

Early adopter program

Running public Astro documentation? Submit a pilot site for setup help, a payload review, and inclusion in the future “Used by” section.

No users or testimonials are displayed without permission.

License

GPL-3.0. See LICENSE.