# directory-index-html

> Make an plain html page containing a directory listing

Latest version **2.1.0** (published 2017-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install directory-index-html
pnpm add directory-index-html
yarn add directory-index-html
bun add directory-index-html
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2017-03-27 |
| First published | 2017-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/directory-index-html
- Repository: https://github.com/mafintosh/directory-index-html
- Issues: https://github.com/mafintosh/directory-index-html/issues
- npm.io page: https://npm.io/package/directory-index-html

## Recent versions

- 2.1.0 (latest) — 2017-03-27
- 2.0.0 — 2017-03-22
- 1.2.0 — 2017-03-08
- 1.1.0 — 2017-02-12
- 1.0.1 — 2017-02-12
- 1.0.0 — 2017-02-12

## README

# directory-index-html

Make an plain html page containing a directory listing.
Similar in look and feel to NGINX's listing page.

```
npm install directory-index-html
```

## Usage

``` js
var toHTML = require('directory-index-html')

var entries = [{
  name: 'test',
  size: 24424,
  mtime: new Date()
}, {
  name: 'a-dir/',
  mtime: new Date()
}]

console.log(toHTML('/foo/bar', entries))
```

## API

#### `var html = toHTML(dir, entries)`

Render a directory name and listing to an plain HTML string.

`dir` should be a string containing the directory name.

`entries` should be an array of entries that are similar to this

``` js
{
  name: 'name-of-file-or-dir',
  size: 42424, // size in bytes
  mtime: new Date() // when was this modified
}
```

To figure out if an entry is a directory the module will one of the following things:

* Check if the path ends with a `/`
* See if `entry.type === 'directory'`
* See if `entry.mode` specifies a directory

## Demo

There is a small demo server bundled in the repo that serves a directory listing of your
current working directory.

To try it out, run `node demo.js` and visit `http://localhost:8080`.

It should show something like this:

![demo.png](demo.png)

## License

MIT

---
_Source: https://npm.io/package/directory-index-html · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
