From 2a2cc9a89f3f291d2ba93e3a4d7eeb3b8ba98bbe Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Mon, 23 Oct 2023 13:38:39 +0800 Subject: [PATCH] revert: Access data files from source folder (#1969) (#5325) --- lib/hexo/index.ts | 2 +- .../filter/before_generate/render_post.ts | 3 +-- test/scripts/filters/render_post.js | 16 ---------------- 3 files changed, 2 insertions(+), 19 deletions(-) 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(); - }); - });