Skip to content

Commit

Permalink
revert: Access data files from source folder (#1969)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Oct 22, 2023
1 parent 3059fa0 commit 74b514b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/hexo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
3 changes: 1 addition & 2 deletions lib/plugins/filter/before_generate/render_post.ts
Original file line number Diff line number Diff line change
@@ -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());
});
Expand Down
16 changes: 0 additions & 16 deletions test/scripts/filters/render_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<p>Hello {{site.data.foo.name}}</p>'
});

const id = page._id;
await renderPost({foo: {name: 'Hexo'}});

page = Page.findById(id);
page.content.trim().should.eql('<p>Hello Hexo</p>');

page.remove();
});

});

0 comments on commit 74b514b

Please sign in to comment.