Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jaredgorski/eleventy-njk-unpkg-inliner

Inline npm modules in Eleventy Nunjucks templates.
https://github.com/jaredgorski/eleventy-njk-unpkg-inliner

eleventy eleventy-plugin inline-javascript

Last synced: 15 days ago
JSON representation

Inline npm modules in Eleventy Nunjucks templates.

Awesome Lists containing this project

README

        


eleventy-njk-unpkg-inliner


Inline npm modules from unpkg in Eleventy Nunjucks templates.



Description


Use this package as part of your [Eleventy](https://github.com/11ty/eleventy/) setup (only with [Nunjucks](https://www.11ty.dev/docs/languages/nunjucks/)) to download modules from [npm](https://www.npmjs.com/) (via [unpkg](https://unpkg.com/)) and include them as inline scripts in your templates via a [shortcode](https://www.11ty.dev/docs/shortcodes/).


Usage


```
npm i eleventy-njk-unpkg-inliner --save-dev
```

#### .eleventy.js
```js
const unpkgInliner = require("eleventy-njk-unpkg-inliner");

module.exports = function(eleventyConfig) {
...

eleventyConfig.addNunjucksAsyncShortcode('unpkgInliner', unpkgInliner);

...
}
```

#### some-template.njk
```html
...

/* use the path from any unpkg URL */
{% unpkgInliner "[email protected]/dist/index.js" %}

...
```