# node-md-meta-cataloger

> A module and CLI for parsing Markdown files (including YAML Front Matter metadata).

Latest version **3.0.0** (published 2023-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-md-meta-cataloger
pnpm add node-md-meta-cataloger
yarn add node-md-meta-cataloger
bun add node-md-meta-cataloger
```

Provides the command `node-md-meta-cataloger`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-08-07 |
| First published | 2018-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=18.12.0 |
| Dependencies | 3 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Joshua Pohl |
| Maintainers | lightpohl |
| Keywords | markdown, md, yaml, metadata, parser, json, catalog |

## Links

- npm: https://www.npmjs.com/package/node-md-meta-cataloger
- Repository: https://github.com/lightpohl/node-md-meta-cataloger
- Homepage: https://github.com/lightpohl/node-md-meta-cataloger#readme
- Issues: https://github.com/lightpohl/node-md-meta-cataloger/issues
- npm.io page: https://npm.io/package/node-md-meta-cataloger

## Dependencies (3)

- [glob](https://npm.io/package/glob.md) ^10.3.3
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [commander](https://npm.io/package/commander.md) ^11.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.0 (latest) — 2023-08-07
- 2.0.0 — 2019-10-03
- 1.2.6 — 2019-10-03
- 1.2.5 — 2019-06-25
- 1.2.4 — 2019-06-23
- 1.2.3 — 2019-02-16
- 1.2.2 — 2018-09-15
- 1.2.1 — 2018-08-29
- 1.2.0 — 2018-08-23
- 1.1.0 — 2018-08-22
- 1.0.2 — 2018-08-19
- 1.0.1 — 2018-08-18
- 1.0.0 — 2018-08-18

## README

# node-md-meta-cataloger

## Easily generate a JSON array of markdown files and their inline metadata.

## Installation

`npm install --save node-md-meta-cataloger`

## How to Use

### CLI Tool

`node-md-meta-cataloger -i <dir> -o <path>`

`node-md-meta-cataloger -i /path/to/folder -o /another/path/catalog.json`

`node-md-meta-cataloger --help`

| Option                | Short Flag | Required | Description                           |
| --------------------- | ---------- | -------- | ------------------------------------- |
| --input \<dir\>       | -i         | true     | input directory path                  |
| --output \<dir\>      | -o         | true     | output path of JSON result            |
| --delete-filename-ext | -d         | false    | remove ".md" from filenames in result |
| --config              | -c         | false    | path to .js config file               |
| --version             | -v         | false    | output the version number             |
| --help                | -h         | false    | output usage information              |

#### Config File (--config)

-   Using the `--config` option you can specify a path to a JS config file (an ES module) that should return a default object exported with "camelCased" versions of the existing CLI options (plus any extra).
-   If an option exists in both the config file and as a CLI option, then the CLI option will receive priority.

| Option            | Type     | Required | Description                                              |
| ----------------- | -------- | -------- | -------------------------------------------------------- |
| input             | String   | true     | input directory path                                     |
| output            | String   | true     | output path of JSON result                               |
| normalize         | Function | false    | receives results as param, returned object is new result |
| sort              | Function | false    | function for `sort`                                      |
| deleteFilenameExt | Boolean  | false    | remove ".md" from filenames in result if true            |

### Node Module

#### `readMarkdown(path : String) : array or object`

Path parameter may reference a markdown file or folder containing markdown files.

1. If passed a path to a folder, it returns an array of objects containing all markdown file content and their associated metadata.
2. If passed a path to a file, it return an object containing the markdown content and its metadata.

```js
import {readMarkdown} from 'node-md-meta-cataloger';

let result = readMarkdown('path/to/folder');
```

Example value of `result` above:

```js
[
    {
        content: '<p>markdown content</p>',
        filename: 'example.md',
        filepath: 'path/to/folder/example.md',
        metadata: {
            title: 'Title',
            author: 'Joshua',
        },
    },
];
```

---
_Source: https://npm.io/package/node-md-meta-cataloger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
