diff --git a/lib/hexo/index.ts b/lib/hexo/index.ts index 21c14183fb..2d347c7bde 100644 --- a/lib/hexo/index.ts +++ b/lib/hexo/index.ts @@ -555,7 +555,7 @@ class Hexo extends EventEmitter { this.emit('generateBefore'); // Run before_generate filters - return this.execFilter('before_generate', this.locals.get('data'), { context: this }) + return this.execFilter('before_generate', null, { context: this }) .then(() => this._routerRefresh(this._runGenerators(), useCache)).then(() => { this.emit('generateAfter'); diff --git a/lib/plugins/filter/before_generate/render_post.ts b/lib/plugins/filter/before_generate/render_post.ts index ae202e9477..539b5dadda 100644 --- a/lib/plugins/filter/before_generate/render_post.ts +++ b/lib/plugins/filter/before_generate/render_post.ts @@ -1,12 +1,11 @@ import Promise from 'bluebird'; -function renderPostFilter(data) { +function renderPostFilter() { const renderPosts = model => { const posts = model.toArray().filter(post => post.content == null); return Promise.map(posts, (post: any) => { post.content = post._content; - post.site = {data}; return this.post.render(post.full_source, post).then(() => post.save()); }); diff --git a/test/scripts/filters/render_post.js b/test/scripts/filters/render_post.js index ab82f405b3..e5540cc7e4 100644 --- a/test/scripts/filters/render_post.js +++ b/test/scripts/filters/render_post.js @@ -46,20 +46,4 @@ describe('Render post', () => { page.remove(); }); - it('use data variables', async () => { - let page = await Page.insert({ - source: 'foo.md', - path: 'foo.html', - _content: '
Hello {{site.data.foo.name}}
' - }); - - const id = page._id; - await renderPost({foo: {name: 'Hexo'}}); - - page = Page.findById(id); - page.content.trim().should.eql('Hello Hexo
'); - - page.remove(); - }); - });