Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/web-alchemy/eleventy-plugin-edgejs
https://github.com/web-alchemy/eleventy-plugin-edgejs
edgejs eleventy eleventy-plugin template-engine
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/web-alchemy/eleventy-plugin-edgejs
- Owner: web-alchemy
- Created: 2022-06-27T06:33:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-09T09:40:43.000Z (over 1 year ago)
- Last Synced: 2024-12-17T17:17:53.646Z (about 2 months ago)
- Topics: edgejs, eleventy, eleventy-plugin, template-engine
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Eleventy Plugin that adds support Edge.js template engine
This plugin allows to use [Edge.js](https://github.com/edge-js/edge/) as template engine for [Eleventy](https://11ty.dev).
## Installation
```
npm install @web-alchemy/eleventy-plugin-edgejs
```## Usage
```javascript
const EdgeJsPlugin = require('@web-alchemy/eleventy-plugin-edgejs')module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EdgeJsPlugin, {
// you can extend current edge instance
extendEdgeInstance: async function (edge, eleventyUserConfig) {
edge.global('version', '1.0.0')edge.registerTag({
block: false,
seekable: true,
tagName: 'rawInclude',
compile (parser, buffer, token) {
const fileName = token.properties.jsArg.trim()
const fullPath = path.join(process.cwd(), eleventyUserConfig.dir.input, fileName)
const fileContent = fs.readFileSync(fullPath, 'utf-8')
buffer.outputRaw(fileContent)
}
})
},// ... or create own new edge instance
createEdgeInstance: async function(eleventyUserConfig) {
const { Edge } = require('edge.js')
const edge = new Edge({
cache: false
})
const { dir } = eleventyUserConfigedge.mount(path.join(cwd, dir.input))
edge.mount('includes', path.join(cwd, dir.input, dir.includes))
return edge
},// optional condition for skipping template rendering
skipRenderCondition: function (inputContent, inputPath) {
return inputPath.includes('components')
}
})
}
```If options has `createEdgeInstance` function, then `extendEdgeInstance` will be ignored.
## Links
- [Edge.js Github Repo](https://github.com/edge-js/edge/)
- [Edge.js docs](https://docs.adonisjs.com/guides/views/introduction)
- [Edge.js references](https://docs.adonisjs.com/reference/views/globals/inspect)
- [Eleventy](https://11ty.dev)