Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"test": "jest lib",
"test-cov": "jest lib --coverage",
"lint": "eslint {src,asset,fixture}/**/*.{js,jsx}",
"lint": "eslint '{src,asset,fixture}/**/*.{js,jsx}'",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed so lint can run inside zsh

"_format": "prettier \"*.{json,babelrc,prettierrc,md}\" \"{.github,*[^lib]}/**/*.{js,jsx,json,yml}\"",
"format": "npm run _format -- --write",
"format-check": "npm run _format -- --check",
Expand Down
8 changes: 7 additions & 1 deletion src/hexo/generator/insight.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ module.exports = function (hexo) {
};
}
const site = {
pages: locals.pages.map(mapPost),
posts: locals.posts.map(mapPost),
tags: locals.tags.map(mapTag),
categories: locals.categories.map(mapTag),
};
const index_pages = ((this.theme.config || {}).search || {}).index_pages;
if (index_pages === false) {
site.pages = [];
} else {
site.pages = locals.pages.map(mapPost);
}

return {
path: '/content.json',
data: JSON.stringify(site),
Expand Down
6 changes: 6 additions & 0 deletions src/hexo/generator/insight.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ test('Export assets file from asset folder', async () => {
(tag) => tag.name === 'tag2' && tag.slug === 'tag2' && tag.link.includes('tag2'),
),
).not.toBeUndefined();

// Test for index_pages=False
hexo.theme.config.search = {}
hexo.theme.config.search.index_pages = false;
const data_nopages = JSON.parse((await generator(locals)).data);
expect(data_nopages.pages.length).toBe(0);
});