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

@slightlyoff/eleventy-plugin-multidoc

v0.1.9

Published

An 11ty plugin for generating multiple output files from a single source document.

Downloads

147

Readme

@slightlyoff/eleventy-plugin-multidoc

A small 11ty plugin for generating multiple output documents from a single markdown file.

Usage

First, install the plugin in your project:

> npm i -s @slightlyoff/eleventy-plugin-multidoc

Then import the plugin in your .eleventy.js (or whatever name you use for your 11ty entrypoint file):

// NOTE: only tested in modern ESM-based projects
import multiDocPlugin from "@slightlyoff/eleventy-plugin-multidoc";

export default async function(config) {

  await config.addPlugin(multiDocPlugin);
  // ...

}

This allows you to write Markdown files whose name end in .multidoc.md that are split by the string <!-- --- -->; e.g. if we had a file located at ./yoursite/postname.multidoc.md containing:

# The First Chunk

 - Each will be output to `<output-dir>/postname/<number>/index.html` 
 - The output directory is configured by 11ty
 - The base directory name is the left-most component of the `*.multidoc.md`
   file name
 - Each internal directory is created in 1-based increments.

This chunk will land in: `<output-dir>/postname/1/index.html`

<!-- --- -->
# A Second Chunk

Output to: `<output-dir>/postname/2/index.html`

<!-- --- -->
---
title: "You can set 11ty through frontmatter sections"
subtitle: "These are also available as page data for processing"
---
# A Third Chunk

Output to: `<output-dir>/postname/3/index.html`

11ty font matter is supported, and templating languages can be mixed with markdown per usual (see below). Each entry also has default next and prev URLs generated in each 11ty entry's .data entry in order to make traversing sets of generated documents easier. If those are provided manually (e.g., via front matter), they will not be overridden. To disable, pass false for the navigation option:

// ...
import multiDocPlugin from "@slightlyoff/eleventy-plugin-multidoc";

export default async function(config) {

  await config.addPlugin(multiDocPlugin, {
    navigation: false,
  });
  
  // ...
}

Controlling Output File Structure

The default output structure may not be convenient, and so an option is provided to alternatively output numbered files, and to rename files using frontmatter.

To output all chunks into a single directory, pass the flatten parameter to the plugin's configuration option, passed as the second parameter when registering:

// .eleventy.js
import multiDocPlugin from "@slightlyoff/eleventy-plugin-multidoc";
// ... 
export default async function(config) {
  await config.addPlugin(multiDocPlugin, {
    flatten: true,
  });
  // ...
}

Using the above example, the output structure would go from:

<output-dir>
└── postname
    ├── 1
    │   └── index.html
    ├── 2
    │   └── index.html
    └── 3
        └── index.html

to:

<output-dir>
└── postname
    ├── 1.html
    ├── 2.html
    └── 3.html

Control of filenames can be configured through frontmatter and combined with flatten: true using either the usual permalink attribute, or a separate filename property:

---
title: "Universal Declaration of Human Rights"
filename: "preamble-1"
---
# Preamble

> Whereas recognition of the inherent dignity and of the equal and inalienable
> rights of all members of the human family is the foundation of freedom, 
> justice and peace in the world,

<!-- --- -->

> Whereas disregard and contempt for human rights have resulted in barbarous
> acts which have outraged the conscience of mankind, and the advent of a world
> in which human beings shall enjoy freedom of speech and belief and freedom
> from fear and want has been proclaimed as the highest aspiration of the
> common people,

<!-- --- -->
---
filename: "postname/preamble-3.html"
# If a filename ends in `.html` that is used verbatim.
---

> Whereas it is essential, if man is not to be compelled to have recourse, as a
> last resort, to rebellion against tyranny and oppression, that human rights
> should be protected by the rule of law,

<!-- ... -->

Which will produce the following files:

<output-dir>
├── 2
│   └── index.html
├── postname
│   └── preamble-3.html
└── preamble-1.html

Advanced Configuration

Stripping Comments

The plugin supports custom file boundary delimiters, as well as pre-processing functions for both the overall source file, as well as individual chunks, to ensure that unwanted content isn't processed across file boundaries. A classic example of this are comments that might span multiple chunks, e.g. if you're using nunjucks in markdown templates.

Here's an example that strips Nunjucks comments before each file is chunked and transformed using the provided function for stripping comments:

// Your project's .eleventy.js
import { multiDocPlugin, commentRemover } from 
    "@slightlyoff/eleventy-plugin-multidoc";

export default async function(config) {
  // ...

  await config.addPlugin(multiDocPlugin, {
    pattern: "**/*.slides.md",
    filePreProcess: commentRemover(),
  });

  // ...

  return {
    markdownTemplateEngine: "njk",
    templateFormats: [ "md", "njk" ],
    // ...
  }
}

Custom file separators

The default separator (<!-- --- -->) can be overridden using the separator parameter. Here, for example, we set it to =====, which must be the entire content of a line:

// .eleventy.js
import multiDocPlugin from "@slightlyoff/eleventy-plugin-multidoc";
// ... 
export default async function(config) {
  await config.addPlugin(multiDocPlugin, { separator: "=====" });
  // ...
}

Pandoc, e.g., uses any Markdown horizontal rule as a document delimiter, which can be re-created using a regular expression:

// .eleventy.js
import multiDocPlugin from "@slightlyoff/eleventy-plugin-multidoc";
// ... 
export default async function(config) {
  await config.addPlugin(multiDocPlugin, {
    // Match 3 or more dashes starting a line, followed by 
    // any number of additional dashes, then any number of 
    // spaces or tabs to the end of a line:
    separator: /^-{3,}\s*$/m,
  });
  // ...
}

When passing a custom separator regular expression, be sure to set the multiline flag (/m) and explicitly match line start and line end to avoid incorrectly matching within content.