Skip to content

Commit

Permalink
hooks to add vento plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Mar 14, 2024
1 parent b39af86 commit 96e3adb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project try to adheres to [Semantic Versioning](https://semver.org/).
Go to the `v1` branch to see the changelog of Lume 1.

## [2.1.2] - Unreleased
## [2.1.2] - 2024-03-14
### Added
- `transform_images` plugin: added the `.webp` extension to the default options.
- `vento` plugin: New option `plugins` to use Vento plugins.
- Added `vento` and `addVentoPlugin` hooks.

### Fixed
- UnoCSS plugin: the async process of adding `<style>` elements is not awaited [#578].
Expand Down Expand Up @@ -314,7 +316,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
[#575]: https://github.com/lumeland/lume/issues/575
[#578]: https://github.com/lumeland/lume/issues/578

[2.1.2]: https://github.com/lumeland/lume/compare/v2.1.1...HEAD
[2.1.2]: https://github.com/lumeland/lume/compare/v2.1.1...v2.1.2
[2.1.1]: https://github.com/lumeland/lume/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/lumeland/lume/compare/v2.0.3...v2.1.0
[2.0.3]: https://github.com/lumeland/lume/compare/v2.0.2...v2.0.3
Expand Down
5 changes: 4 additions & 1 deletion deps/vento.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export { default as engine } from "https://deno.land/x/[email protected]/mod.ts";
export { FileLoader } from "https://deno.land/x/[email protected]/src/loader.ts";

export type { Environment } from "https://deno.land/x/[email protected]/src/environment.ts";
export type {
Environment,
Plugin,
} from "https://deno.land/x/[email protected]/src/environment.ts";
export type { Token } from "https://deno.land/x/[email protected]/src/tokenizer.ts";
13 changes: 12 additions & 1 deletion plugins/vento.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type Site from "../core/site.ts";
import type { Data } from "../core/file.ts";
import type { Engine, Helper, HelperOptions } from "../core/renderer.ts";
import type FS from "../core/fs.ts";
import type { Environment, Token } from "../deps/vento.ts";
import type { Environment, Plugin, Token } from "../deps/vento.ts";

export interface Options {
/** The list of extensions this plugin applies to */
Expand All @@ -22,6 +22,11 @@ export interface Options {
*/
includes?: string;

/**
* Plugins to use by vento
*/
plugins?: Plugin[];

/**
* The options for the Vento engine
* @see https://vento.js.org/configuration/
Expand Down Expand Up @@ -127,6 +132,12 @@ export default function (userOptions?: Options) {
});

vento.tags.push(compTag);
options.plugins?.forEach((plugin) => vento.use(plugin));

site.hooks.addVentoPlugin = (plugin: Plugin) => {
vento.use(plugin);
};
site.hooks.vento = (callback) => callback(vento);

const ventoEngine = new VentoEngine(vento, options.includes);

Expand Down

0 comments on commit 96e3adb

Please sign in to comment.