diff --git a/lib/theme/index.ts b/lib/theme/index.ts index d8cf042203..3d6dfb1259 100644 --- a/lib/theme/index.ts +++ b/lib/theme/index.ts @@ -2,6 +2,10 @@ import {extname} from 'path'; import Box from '../box'; import View from './view'; import I18n from 'hexo-i18n'; +import { config } from './processors/config'; +import { i18n } from './processors/i18n'; +import { source } from './processors/source'; +import { view } from './processors/view'; class Theme extends Box { public config: any; @@ -17,10 +21,10 @@ class Theme extends Box { this.views = {}; this.processors = [ - require('./processors/config'), - require('./processors/i18n'), - require('./processors/source'), - require('./processors/view') + config, + i18n, + source, + view ]; let languages = ctx.config.language; diff --git a/lib/theme/processors/config.ts b/lib/theme/processors/config.ts index 2da78854d6..7d4288eb0f 100644 --- a/lib/theme/processors/config.ts +++ b/lib/theme/processors/config.ts @@ -1,6 +1,6 @@ import {Pattern} from 'hexo-util'; -export function process(file) { +function process(file) { if (file.type === 'delete') { file.box.config = {}; return; @@ -15,4 +15,9 @@ export function process(file) { }); } -export const pattern = new Pattern(/^_config\.\w+$/); +const pattern = new Pattern(/^_config\.\w+$/); + +export const config = { + pattern: pattern, + process: process +} diff --git a/lib/theme/processors/i18n.ts b/lib/theme/processors/i18n.ts index fcdc457aae..f6172f4b4d 100644 --- a/lib/theme/processors/i18n.ts +++ b/lib/theme/processors/i18n.ts @@ -1,7 +1,7 @@ import {Pattern} from 'hexo-util'; import {extname} from 'path'; -export function process(file) { +function process(file) { const { path } = file.params; const ext = extname(path); const name = path.substring(0, path.length - ext.length); @@ -18,4 +18,9 @@ export function process(file) { }); } -export const pattern = new Pattern('languages/*path'); +const pattern = new Pattern('languages/*path'); + +export const i18n = { + pattern: pattern, + process: process +} \ No newline at end of file diff --git a/lib/theme/processors/source.ts b/lib/theme/processors/source.ts index f7ff6a4a0c..52bde14059 100644 --- a/lib/theme/processors/source.ts +++ b/lib/theme/processors/source.ts @@ -1,7 +1,7 @@ import {Pattern} from 'hexo-util'; import * as common from '../../plugins/processor/common'; -export function process(file) { +function process(file) { const Asset = this.model('Asset'); const id = file.source.substring(this.base_dir.length).replace(/\\/g, '/'); const { path } = file.params; @@ -22,7 +22,7 @@ export function process(file) { }); } -export const pattern = new Pattern(path => { +const pattern = new Pattern(path => { if (!path.startsWith('source/')) return false; path = path.substring(7); @@ -30,3 +30,9 @@ export const pattern = new Pattern(path => { return {path}; }); + + +export const source = { + pattern: pattern, + process: process +} \ No newline at end of file diff --git a/lib/theme/processors/view.ts b/lib/theme/processors/view.ts index bb0d44d1f8..600295a8c3 100644 --- a/lib/theme/processors/view.ts +++ b/lib/theme/processors/view.ts @@ -1,6 +1,6 @@ import { Pattern } from 'hexo-util'; -export function process(file) { +function process(file) { const { path } = file.params; if (file.type === 'delete') { @@ -13,4 +13,9 @@ export function process(file) { }); } -export const pattern = new Pattern('layout/*path'); +const pattern = new Pattern('layout/*path'); + +export const view = { + pattern: pattern, + process: process +} \ No newline at end of file