open-index/open-npm huggingface dataset:
npm package: @humanwhocodes/astro-jekyll
Description: Astro helpers for Jekyll compatibility.
Author: Nicholas C. Zaks
Latest version: 1.0.1

# Astro Jekyll Compatibility Package

by [Nicholas C. Zakas](https://humanwhocodes.com)

If you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate).

## Description

Allows [Astro](https://astro.build) to understand Markdown formatted in the manner that [Jekyll](https://jekyllrb.com) to make transitioning from Jekyll to Astro easier.

See the `example-site` folder for an example.

## Requirements

* Node.js v18+
* Astro v2.0+

## Installation

Install using [npm][npm] or [yarn][yarn]:

```
npm install @humanwhocodes/astro-jekyll

# or

yarn add @humanwhocodes/astro-jekyll
```

## Usage

This package exports the following:

* `parseJekyllDateTime()` - a utility function to convert Jekyll-formatted datetime strings into JavaScript `Date` objects.
* `formatJekyllPermalink()` - a utility function to populate a Jekyll permalink string with post information.
* `formatJekyllPost()` - a function that returns a function you can use to format posts using Jekyll frontmatter.

Import into your Astro project:

```js
import {
    parseJekyllDateTime,
    formatJekyllPermalink,
    formatJekyllPost
} from "@humanwhocodes/async-event-emitter";
```

In general, you'll probably only ever need `formatJekyllPost()`, which you use after calling `getCollection()`, like this:

```js
import { CollectionEntry, getCollection } from 'astro:content';	
    
const posts = (await getCollection('blog'))
    .map(formatJekyllPost());
```

Each `CollectionEntry` object is then populated with the Jekyll-style frontmatter and ready to be used elsewhere in Astro.

By default, `formatJekyllPost()` assumes a permalink format of `/blog/:year/:month/:title`. You can change it by passing in a custom permalink format:

```js
import { CollectionEntry, getCollection } from 'astro:content';	
    
const posts = (await getCollection('blog'))
    .map(formatJekyllPost({
        permalink: "/snippets/:short_year/:month/:title/"
    }));
```

The first part of the permalink (in this case, `snippets`) is assumed to be the directory your `[...slug].astro` file is in and will be stripped off. It's only used for proper placement in the string and to make it easy to copy-paste permalinks directly from Jekyll.

The following placeholders are supported:

* `:year`
* `:short_year`
* `:month`
* `:i_month`
* `:day`
* `:i_day`
* `:hour`
* `:minute`
* `:second`
* `:title`
* `:slug`

Pull requests gratefully accepted for adding the remaining Jekyll placeholders.

## License

Apache 2.0
npm package: @humanwhocodes/async-event-emitter
Description: Async event emitter
Author: Nicholas C. Zaks
Latest version: 1.0.1

# AsyncEventEmitter

by [Nicholas C. Zakas](https://humanwhocodes.com)

If you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate).

## Description

A utility for emitting events and responding with asynchronous functions.

## Usage

### Node.js

Install using [npm][npm] or [yarn][yarn]:

```
npm install @humanwhocodes/async-event-emitter

# or

yarn add @humanwhocodes/async-event-emitter
```

Import into your Node.js project:

```js
// CommonJS
const { AsyncEventEmitter } = require("@humanwhocodes/async-event-emitter");

// ESM
import { AsyncEventEmitter } from "@humanwhocodes/async-event-emitter";
```


### Deno

Import into your Deno project:

```js
import { AsyncEventEmitter } from "https://cdn.skypack.dev/@humanwhocodes/async-event-emitter?dts";
```

### Bun

Install using this command:

```
bun add @humanwhocodes/async-event-emitter
```

Import into your Bun project:

```js
import { AsyncEventEmitter } from "@humanwhocodes/async-event-emitter";
```

### Browser

It's recommended to import the minified version to save bandwidth:

```js
import { AsyncEventEmitter } from "https://cdn.skypack.dev/@humanwhocodes/async-event-emitter?min";
```

However, you can also import the unminified version for debugging purposes:

```js
import { AsyncEventEmitter } from "https://cdn.skypack.dev/@humanwhocodes/async-event-emitter";
```

## API

After importing, create a new instance of `AsyncEventEmitter` to start emitting events:

```js
const emitter = new AsyncEventEmitter();

// add some event handlers - functions can be async or not
emitter.on("foo", async () => "hello!");
emitter.on("foo", () => "goodbye!");

// emit an event
const results = await emitter.emit("foo");
console.log(results);   // ["hello!", "goodbye!"]

// you can also pass arguments
emitter.on("exclaim", suffix => "hello" + suffix);
emitter.on("exclaim", suffix => "goodbye" + suffix);

const results = await emitter.emit("exclaim", "!");
console.log(results);   // ["hello!", "goodbye!"]

// get the number of handlers for an event
const count = emitter.listenerCount("exclaim");
console.log(count);     // 2

// remove any unwanted handlers
const handler = () => {};
emitter.on("bar", handler);
emitter.off("bar", handler);

const results = await emitter.emit("bar");
console.log(results);   // []

```

## Developer Setup

1. Fork the repository
2. Clone your fork
3. Run `npm install` to setup dependencies
4. Run `npm test` to run tests

## License

Apache 2.0

[npm]: https://npmjs.com/
[yarn]: https://yarnpkg.com/