# eleventy-plugin-drawio

> Embed local .drawio diagrams in your eleventy site

Latest version **0.3.0** (published 2023-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install eleventy-plugin-drawio
pnpm add eleventy-plugin-drawio
yarn add eleventy-plugin-drawio
bun add eleventy-plugin-drawio
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2023-06-27 |
| First published | 2022-09-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | kev4ev |
| Maintainers | kev4ev |
| Keywords | eleventy, 11ty, drawio, diagrams.net |

## Links

- npm: https://www.npmjs.com/package/eleventy-plugin-drawio
- Repository: https://github.com/kev4ev/eleventy-plugin-drawio
- Issues: https://github.com/kev4ev/eleventy-plugin-drawio/issues
- npm.io page: https://npm.io/package/eleventy-plugin-drawio

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.3.0 (latest) — 2023-06-27
- 0.2.0 — 2022-10-03
- 0.1.0 — 2022-09-13

## README

# eleventy-plugin-drawio

This eleventy (`@11ty/eleventy`) plugin allows you to embed interactive diagrams from from local `.drawio` files into your website pages. It does this by adding a simple <a href="https://www.11ty.dev/docs/shortcodes/" target="_blank">shortcode</a> that you can compose into your templates. First add the plugin to your **.eleventy.js** file:

## Installation

```sh
npm i --save eleventy-plugin-drawio
```

## Usage

This package is built primarily as a [plugin](#plugin) to the eleventy site generator, but it also exposes a [standalone API](#api) that you can call directly in your scripts.

### `eleventy` Plugin <span id="plugin"></span>

```js
const drawio = require('eleventy-plugin-drawio');

// add the plugin to your eleventy config
module.exports = function(eleventyConfig){
    eleventyConfig.addPlugin(drawio);
    /** other code here */
    return {
        // your config
    }
}
```

Now you can use the `drawio` shortcode in your template files as such:

```html
<!-- nunjucks syntax -->
<iframe src="{% drawio <pathToDrawioFile> [, enableEdit] [, page] %}" />
```

The shortcode **requires** the argument `<pathToDrawioFile>` which must be: 
- relative to your _project root_ (where the `.eleventy.js` file lives), and
- must include the _.drawio_ file suffix

Optional args: 

Arg | Type | Default | Description
--|--|--|--
`enableEdit` | boolean | `false` | when true, passes path param `'edit=_blank&'` which allows viewers to edit a new copy of your diagram
`page` | integer | `undefined` | when provided, passes path param `page=<page>` which tells drawio to automatically render the diagram at the given page

### Programmatic API <span id="api"></span>
You can call the internal package API in your scripts directly by using a subpath require:

```js
const drawio = require('eleventy-plugin-drawio/api');
// ...
```

Currently the API exposes a single function. 

### `generateAddress(relPath, edit=false, page)`
Call this function to generate a URL from your draw.io diagram that can be used as an `iframe src` or as a direct link.

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