# enoki

> A Choo plugin for reading a content directory with Hypha

Latest version **2.1.0** (published 2018-04-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install enoki
pnpm add enoki
yarn add enoki
bun add enoki
```

Provides the command `enoki`.

## 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 | 2018-04-25 |
| First published | 2017-08-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 35.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 225 |
| Author | Jon-Kyle |
| Maintainers | jondashkyle |

## Links

- npm: https://www.npmjs.com/package/enoki
- Repository: https://github.com/enokidotsite/enoki
- Homepage: https://github.com/enokidotsite/enoki#readme
- Issues: https://github.com/enokidotsite/enoki/issues
- npm.io page: https://npm.io/package/enoki

## Dependencies (10)

- [xhr](https://npm.io/package/xhr.md) ^2.4.1
- [hypha](https://npm.io/package/hypha.md) ^0.4.5
- [xtend](https://npm.io/package/xtend.md) ^4.0.1
- [yargs](https://npm.io/package/yargs.md) ^11.0.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [chokidar](https://npm.io/package/chokidar.md) ^2.0.3
- [nanopage](https://npm.io/package/nanopage.md) 0.0.1-next.3
- [object-keys](https://npm.io/package/object-keys.md) ^1.0.11
- [object-values](https://npm.io/package/object-values.md) ^1.0.0
- [parse-dat-url](https://npm.io/package/parse-dat-url.md) ^3.0.1

## Recent versions

- 2.1.0 (latest) — 2018-04-25
- 2.2.0-next4 (next) — 2018-05-30
- 2.2.0-next3 — 2018-05-26
- 2.2.0-next2 — 2018-05-26
- 2.2.0-next1 — 2018-05-26
- 2.0.8-next.8 — 2018-04-23
- 2.0.8-next.7 — 2018-04-23
- 2.0.8-next.6 — 2018-04-23
- 2.0.8-next.5 — 2018-04-22
- 2.0.8-next.4 — 2018-04-22
- 2.0.8-next.3 — 2018-04-21
- 2.0.8-next.2 — 2018-04-21
- 2.0.8-next.1 — 2018-04-13
- 2.0.7-next.2 — 2018-04-13
- 2.0.7-next.1 — 2018-04-13
- … 18 more at https://npm.io/package/enoki/versions

## README

<h1 align="center">Enoki</h1>

Enoki is a powerfully simple set of tools and interfaces for creating and managing websites and single-page-apps. It’s as vanilla as possible, meant to get out of your way, and play nice with traditional tooling as well as unique environments, such as the peer-to-peer [Beaker Browser](https://beakerbrowser.com).

Although fully-featured, Enoki is still early in development. Support for other frameworks and syntax styles are on the roadmap. If something you’d like to see is missing, please feel free to contribute!

## Features

- **no-db**: just files and folders
- **simple**: written for clarity
- **tools**: easy ways of traversing data
- **cute**: first class support for [choo](https://github.com/choojs/choo), a simple and sturdy front-end framework
- **panel**: manage your content with a [super simple and extensible interface](https://github.com/enokidotsite/)

## Usage

Although the Enoki library can be used in a variety of ways, for the sake of example let’s just create a fresh little Choo app and require `enoki/choo`:

```js
var choo = require('choo')
var app = choo()

app.use(require('enoki/choo')())
```

Create a `/content` directory in the root of your project and make an `index.txt` file. Pages (and sub-pages) are just folders with their own `index.txt` files:

```
title: Enoki Example
----
text: Hey, not bad!
```

Inside your Choo views you can traverse your content with a super handy API:

```js
var html = require('choo/html')

function view (state, emit) {
  var page = state.page
  var children = page().children().sort('title', 'asc').value()

  return html`
    <body>
      <h1>${page.value('title')}</h1>
      <article>${page.value('text')}</article>
      <ul>
        ${children.map(renderChild)}
      </ul>
    </body>
  `

  function renderChild (props) {
    var child = page(props)
    return html`
      <li>
        <a href="${child.value('url')}">${child.value('title')}</a>
      </li>
    `
  }
}
``` 

### Peer-to-Peer / Dat

The web is becoming re-decentralized! You can use Enoki with [Dat](https://datproject.org) in an environment such as [Beaker Browser](https://beakerbrowser.com) by swapping Node’s `fs` for the `DatArchive` API. This enables real-time reading of the archives’s files. Ensure you’re using `.readAsync()`.

### HTTP Fallback and CLI

When using Enoki in a Dat environment we use the `DatArchive` API instead of Node’s `fs` to read the archive’s files. However, over `http` Enoki reads a static `json` file for fallback.

If you’d like to output that static `json` when developing your site you can use the Enoki `cli`. It’s possible to watch your content directory for changes by using the `--watch` flag.

```
enoki content
enoki content --watch
```

### Note

Enoki is early in development. If you’d like to see support for webpack, or whatever other tooling, feel free to contribute!

## Dependencies

For specifics on formatting directories and files, take a look at the dependencies’ documentation.

- [`smarkt`](https://github.com/jondashkyle/smarkt) for parsing mixed key/value store and yaml plain text files
- [`hypha`](https://github.com/jondashkyle/hypha) for turning folders and files into json

## Page API

Enoki exposes a super convenient way for traversing flat content state called [`nanopage`](https://github.com/jondashkyle/nanopage).

You can access it like so:

```
var Page = require('enoki/page')
```

Alternatively, if you’re using Choo you can access `nanopage` over state:

```
state.page().title().value()
```

For a complete list of methods, take a look [at the docs](https://github.com/jondashkyle/nanopage)!

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