Skip to content

Commit

Permalink
split utils into separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
noelforte committed Nov 26, 2024
1 parent dd4c379 commit e06a83a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type { Plugin, Template } from 'ventojs/src/environment.js';
import type { EleventyFunctionMap, EleventyVentoEnv, PageData } from './types.js';

// Internal modules
import { createVentoTag } from './create-vento-tag.js';
import { debugCache, debugRender } from './utils.js';
import { createVentoTag } from './utils/create-vento-tag.js';
import { debugCache, debugRender } from './utils/debuggers.js';

export function createVentoEngine(options: Options) {
const env = ventojs(options) as EleventyVentoEnv;
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import path from 'node:path';

// External modules
import type { UserConfig } from '@11ty/eleventy';
import type { PageData } from './types.js';
import autotrimPlugin, { defaultTags as autotrimDefaultTags } from 'ventojs/plugins/auto_trim.js';
import type { PageData } from './types.js';

// Local modules
import { createVentoEngine, renderVentoTemplate } from './engine.js';
import { debugMain, debugCache, compatibilityCheck } from './utils.js';
import type { VentoPluginOptions } from './types.js';
import { compatibilityCheck } from './utils/compat-check.js';
import { debugCache, debugMain } from './utils/debuggers.js';

export function VentoPlugin(eleventyConfig: UserConfig, userOptions: Partial<VentoPluginOptions>) {
debugMain('Initializing eleventy-plugin-vento');
Expand Down
8 changes: 1 addition & 7 deletions src/utils.ts → src/utils/compat-check.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// Set up debugger global
import type { UserConfig } from '@11ty/eleventy';
import createDebugger from 'debug';

const debugBaseNamespace = 'Eleventy:Vento';

export const debugMain = createDebugger(debugBaseNamespace);
export const debugCache = createDebugger(`${debugBaseNamespace}:Cache`);
export const debugRender = createDebugger(`${debugBaseNamespace}:Render`);
import { debugMain } from './debuggers.js';

// Project-wide constants
export const REQUIRED_API_METHODS = [
Expand Down
2 changes: 1 addition & 1 deletion src/create-vento-tag.ts → src/utils/create-vento-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import type { Tag } from 'ventojs/src/environment.js';
import type { TagSpec } from './types.js';
import type { TagSpec } from '../types.js';

export function createVentoTag(spec: TagSpec) {
const IS_PAIRED = spec.group === 'pairedShortcodes';
Expand Down
7 changes: 7 additions & 0 deletions src/utils/debuggers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import createDebugger from 'debug';

const debugBaseNamespace = 'Eleventy:Vento';

export const debugMain = createDebugger(debugBaseNamespace);
export const debugCache = createDebugger(`${debugBaseNamespace}:Cache`);
export const debugRender = createDebugger(`${debugBaseNamespace}:Render`);

0 comments on commit e06a83a

Please sign in to comment.