# glorybook

> Webpack plugin for creating storybook pages from contentful data

Latest version **1.2.1** (published 2019-11-09) · ISC license · 0 weekly downloads

## Install

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

## 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 | 1.2.1 |
| Published | 2019-11-09 |
| First published | 2019-11-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 10.* |
| Dependencies | 2 |
| Unpacked size | 40.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Erik Thalén |
| Maintainers | erikthalen |
| Keywords | storybook, contentful, webpack |

## Links

- npm: https://www.npmjs.com/package/glorybook
- Repository: https://github.com/erikthalen/glorybook-plugin
- Issues: https://github.com/erikthalen/glorybook-plugin/issues
- npm.io page: https://npm.io/package/glorybook

## Dependencies (2)

- [contentful](https://npm.io/package/contentful.md) ^7.10.0
- [@contentful/rich-text-html-renderer](https://npm.io/package/@contentful/rich-text-html-renderer.md) ^13.4.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2019-11-09
- 1.0.1-beta.1 (beta) — 2019-11-05
- 1.2.0 — 2019-11-07
- 1.1.0 — 2019-11-06
- 1.0.1-beta.0 — 2019-11-05
- 1.0.0-beta.2 — 2019-11-05
- 1.0.0-beta.1 — 2019-11-05
- 1.0.0-beta.0 — 2019-11-05

## README

![Image of contentful-, webpack- and storybook logo](https://i.ibb.co/1LpNxmJ/image.jpg)
# Glorybook

A webpack plugin to use in conjunction with [@storybook/addons-docs](https://github.com/storybookjs/storybook/tree/master/addons/docs).  

Will take your contentful data and turn it into a markdown file that storybook can read.

## Install

```bash
npm i --save-dev glorybook
```

```bash
yarn add --dev glorybook
```

## Usage

The plugin will fetch data from the supplied contentful space, and output .mdx-files inside your webpack /src-folder.
By default the created files are put in a subfolder named `/contentful`.

*Be sure to not expose your space/access token in your public code*

**webpack.config.js**
```javascript
const GlorybookPlugin = require("glorybook");

module.exports = {
  plugins: [
    new GlorybookPlugin({
      space: 'contentful space id', // required
      accessToken: 'contentful access token' // required
    })
  ]
}
```

## Example

This setup in your contentful content model:  
![Screenshot of contentful UI](https://i.ibb.co/kMWqPhf/contentful-screen.jpg)

Will output this in storybook:  
![Screenshot of storybook UI](https://i.ibb.co/Myv1vRP/storybook-screen.jpg)

With a file structure like this:
```
📦src
 ┗ 📂contentful
   ┗ 📂parent
     ┗ 📂child-folder
       ┗ 📜nested-page.stories.mdx
```

**The plugin can currently handle**
- Rich text
- Images (single)
- Videos (single)
- Referenced content, including all of the above

## Options

| Name             | Type       | Default         | Description                                                                                                                    |
| ---------------- | ---------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `environment`    | `{String}` | `'master'`      | Defines what contentful environment you want to get data from.                                                                 |
| `srcFolder`      | `{String}` | `'/src'`        | Defines where your src-folder lives.                                                                                           |
| `subFolder`      | `{String}` | `'/contentful'` | Defines where the generated files will be put, inside the `srcFolder`                                                          |
| `contentTypeId`  | `{String}` | `'page'`        | The id of your contentful pages that you like to fetch                                                                         |
| `additionalHead` | `{String}` | `''`            | If you have more content you like to paste in the top of every file                                                            |
| `camelCase`      | `{Bool}`   | `false`         | If you want the generated files to be named in in camelCase. When `false`, they will be in kebab-case                          |
| `fullPathOutput` | `{Bool}`   | `false`         | When the page is nested, this will keep the full relative path in the filename. When `false`, only the last part will be kept. |
| `nestedOutput`   | `{Bool}`   | `true`          | If the files should be placed in folders just like in storyfull. `false` will place all files in the,un-nested , `subFolder`   |
| `labelDefinedBy` | `{String}` | `'label'`       | The id your contentful entry that defines label the file will be placed under                                                  |
| `pathDefinedBy`  | `{String}` | `'path'`        | The id your contentful entry that defines what path/filename the file will get                                                 |
  

---

## Dev-notes

The `/demo`-folder is used for previewing any test output during development of this plugin.  
This folder has a copy of storybook installed in order for us to run the plugin and have a real-world environment to sandbox in.  

For getting started with building on this project, run:
```bash
yarn inst
```
This will install all dependencies needed for both the plugin, and the demo environment.  

When any changes are made ...
```bash
yarn build
```
... will output files, applying the passed options specified in the `webpack.config.js`  

```bash
yarn demo
```
Can be run in order to build and startup the storybook inside `/demo`. This is currently used for testing. In a very WYSIWYG-fashion.

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